commit on NullPointerException

From: "Guthrie, John" <JGuthrie(at)air(dot)org>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: commit on NullPointerException
Date: 2002-06-13 20:09:27
Message-ID: F779B05379CAD2118BD20090273017BF03E79C28@dc1.air.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tom Lane 2002-06-13 20:32:00 Re: Problem with JTA/JTS
Previous Message Barry Lind 2002-06-13 20:01:57 Re: Problem with JTA/JTS