On 02/11/2013 05:34 PM, Matti Aarnio wrote: > On 02/11/2013 02:11 PM, Heikki Linnakangas wrote: >> Works for me: >> >> postgres=# do $$ >> begin >> insert into example values ('2001-01-01', 'foo', 'bar'); >> insert into example values ('2001-01-01', 'foo', 'bar'); >> exception >> when others then raise notice 'caught %', sqlstate; >> end; >> $$; >> NOTICE: caught 23505 >> DO >> >> How exactly are you seeing the wrong status code? What client are you >> using? > I am calling PostgreSQL JDBC driver through Tomcat 7 Pool manager.. > Which could of course scramble the status code report (unlikely, but > possible..) > > The driver binary I was using is: postgresql-9.0-801.jdbc3.jar > > Switching to jdbc4 driver binary of otherwise same version makes no > difference. > Neither switching to latest version makes any difference: > postgresql-9.2-1002.jdbc4.jar
Catching the SQLException, and printing the backtrace shows: 2013-02-11 17:47:08,559 [http-bio-8080-exec-7] ERROR fi.methics.ExampleDatabase - Insert into example at jdbc:kiuru:pool:example resulted unexpected SQL Exception code: 0 ERROR: duplicate key value violates unique constraint "replay_attack_detector_pkey" Detail: Key (a, b, c)=(a, b, 2013-02-11 17:47:08.163) already exists. org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "example_pkey" Detail: Key (a, b, c)=(a, b, 2013-02-11 17:47:08.163) already exists. at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:363) at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport$StatementProxy.invoke(AbstractQueryReport.java:235) at $Proxy7.executeUpdate(Unknown Source) at fi.methics.ExampleDatabase.exampleInsert(ExampleDatabase.java:123) ....
smime.p7s
Description: S/MIME Cryptographic Signature