Re: commit and rollback don't throw exceptions when they should
От | Oliver Jowett |
---|---|
Тема | Re: commit and rollback don't throw exceptions when they should |
Дата | |
Msg-id | 4AE0164C.5010805@opencloud.com обсуждение исходный текст |
Ответ на | commit and rollback don't throw exceptions when they should ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>) |
Ответы |
Re: commit and rollback don't throw exceptions when
theyshould
|
Список | pgsql-jdbc |
taktos wrote: > I made a groovy code that tests whether Connection#commit() throws > excepton when connection has been closed. > > http://github.com/taktos/JDBC-Driver-Test/blob/master/ConnectionTest.groovy > > I tested in environment below: > Oracle 10g XE (ojdbc14.jar and ojdbc6.jar) > MySQL 5.1 (mysql-connector-java-5.1.10.jar) > h2database (h2-1.2.121.jar) > PostgreSQL 8.3 (postgresql-8.3.605.jdbc4.jar) > > Drivers other than PosrgreSQL throws exception as I had expected, but > PostgreSQL didn't throw exception. Yes, that is the case I mentioned where there have been no commands executed in the transaction. In that case, the driver has no work to do on commit() so it does not notice the connection was closed. Even if we added a check for an explicit Connection.close() call before Connection.commit(), that would not help with your test where you are shutting down the server. The driver will only notice the network connection is gone when it next tries to actually send or receive data. Try adding a simple query ("SELECT 1", or whatever) to your test, and you should see an exception on close. -O
В списке pgsql-jdbc по дате отправления: