Re: Expressiveness of SQLException

From: Daniel Migowski <dmigowski(at)ikoffice(dot)de>
To: pgsql-jdbc(at)postgresql(dot)org
Cc: Oliver Jowett <oliver(at)opencloud(dot)com>, Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Subject: Re: Expressiveness of SQLException
Date: 2008-04-24 15:06:37
Message-ID: 4810A1FD.3080103@ikoffice.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Thank you for your responses. Sadly, they don't help me (with PG 8.3 and
the JDBC-3-Driver).

This is my SQL:

CREATE OR REPLACE FUNCTION fail() RETURNS int4 AS
$BODY$ BEGIN RAISE exception 'FAIL'; return null; END; $BODY$ LANGUAGE
'plpgsql';

CREATE OR REPLACE FUNCTION fail2()RETURNS int4 AS
$BODY$ BEGIN select fail(); return null; END; $BODY$ LANGUAGE 'plpgsql';

select fail2();

And this the result:

ERROR: FAIL
SQL Status:P0001
Kontext:SQL statement "select fail()"
PL/pgSQL function "fail2" line 1 at SQL statement

Now when called from Java:

try {
ResultSet r = stmt.executeQuery("select fail2();");
JdbcUtils.dumpResultSet(r);
} catch (SQLException e) {
e.printStackTrace();
PSQLException ex = (PSQLException)e;
System.err.println(ex.getServerErrorMessage());
System.err.println(ex.getSQLState());
System.err.println(ex.getErrorCode());
System.err.println(ex.getNextException());
System.err.println(ex.getCause());
}

I get this result:

org.postgresql.util.PSQLException: ERROR: function fail2() does not exist
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1559)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:192)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:336)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:235)
at de.ikoffice.jdbc.JdbcExceptionsTest.main(JdbcExceptionsTest.java:24)
ERROR: function fail2() does not exist
42883
0
null
null

where is no more information from the functions you proposed. Is this a bug?

With best regards,
Daniel Migowski

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Chris 2008-04-24 17:25:16 Can't use a variable for a column name?
Previous Message Oliver Jowett 2008-04-24 14:00:42 Re: Expressiveness of SQLException