commit on NullPointerException - Mailing list pgsql-jdbc

From Guthrie, John
Subject commit on NullPointerException
Date
Msg-id F779B05379CAD2118BD20090273017BF03E79C28@dc1.air.org
Whole thread Raw
List pgsql-jdbc
I am using poolman to cache database connections, and I am seeing some odd
behavior. Before I go digging into both postgres JDBC and poolman, I am
hoping someone can point me down the right path (or even explain why it
should do this).

Anyway, what happens is that I get a connection from poolman and set
autoCommit to false. I then do a few inserts, and whoops I have a bug that
throws a NullPointerException. This happens before I call commit(). In my
finally block I return the connection to the pool (I also set autoCommit
back to whatever it was).

The strange thing is that the inserts I have done are not rolled back, they
are committed. I know I can fix this by adding a rollback to my finally
block (I've actually done this, and it works), but I was sort of expecting
an auto-rollback-if-not-committed. Also, I like to idiot-proof my code as
much as possible, so if there's a way to get it to behave as I want it to
automatically I'd prefer that.

All advice welcome. Thanks.
John Guthrie

pgsql-jdbc by date:

Previous
From: Barry Lind
Date:
Subject: Re: Problem with JTA/JTS
Next
From: Tom Lane
Date:
Subject: Re: Problem with JTA/JTS