View Single Post

   
  #1 (permalink)  
Old 04-16-2008, 12:59 AM
sulfinu@gmail.com
 
Posts: n/a
Default unnecessary exception patch

Hi,

this is a patch that avoids getting an undeserved PSQLException when setting
the transaction isolation level on a connection:

---
postgresql-jdbc-8.2-507.src/org/postgresql/jdbc2/AbstractJdbc2Connection.java
2007-12-01 11:17:49.000000000 +0200
+++ src/org/postgresql/jdbc2/AbstractJdbc2Connection.java 2008-01-11
15:26:58.000000000 +0200
@@ -759,6 +759,8 @@
*/
public void setTransactionIsolation(int level) throws SQLException
{
+ if (level == getTransactionIsolation())
+ return;
if (protoConnection.getTransactionState() !=
ProtocolConnection.TRANSACTION_IDLE)
throw new PSQLException(GT.tr("Cannot change transaction
isolation level in the middle of a transaction."),
PSQLState.ACTIVE_SQL_TRANSACTION);


It applies to the case when a connection is reused within a connection pool
and some of its properties are automatically reset before the connection is
handed to the requesting party.
Example: the default DriverManagerConnectionProvider in Hibernate.

Regards.

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply With Quote