Index: org/postgresql/jdbc2/AbstractJdbc2Connection.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java,v retrieving revision 1.52 diff -c -r1.52 AbstractJdbc2Connection.java *** org/postgresql/jdbc2/AbstractJdbc2Connection.java 1 Jul 2009 05:00:40 -0000 1.52 --- org/postgresql/jdbc2/AbstractJdbc2Connection.java 4 Nov 2009 22:28:59 -0000 *************** *** 676,691 **** * The method commit() makes all changes made since the previous * commit/rollback permanent and releases any database locks currently * held by the Connection. This method should only be used when ! * auto-commit has been disabled. (If autoCommit == true, then we ! * just return anyhow) * ! * @exception SQLException if a database access error occurs * @see setAutoCommit */ public void commit() throws SQLException { if (autoCommit) ! return ; if (protoConnection.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE) executeTransactionCommand(commitQuery); --- 676,697 ---- * The method commit() makes all changes made since the previous * commit/rollback permanent and releases any database locks currently * held by the Connection. This method should only be used when ! * auto-commit has been disabled. * ! * @exception SQLException if a database access error occurs, ! * this method is called on a closed connection or ! * this Connection object is in auto-commit mode * @see setAutoCommit */ public void commit() throws SQLException { + if (isClosed()) + throw new PSQLException(GT.tr("Cannot commit when connection is closed."), + PSQLState.CONNECTION_FAILURE); + if (autoCommit) ! throw new PSQLException(GT.tr("Cannot commit when autoCommit is enabled."), ! PSQLState.NO_ACTIVE_SQL_TRANSACTION); if (protoConnection.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE) executeTransactionCommand(commitQuery); *************** *** 696,708 **** * commit/rollback and releases any database locks currently held by * the Connection. * ! * @exception SQLException if a database access error occurs * @see commit */ public void rollback() throws SQLException { if (autoCommit) ! return ; if (protoConnection.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE) executeTransactionCommand(rollbackQuery); --- 702,721 ---- * commit/rollback and releases any database locks currently held by * the Connection. * ! * @exception SQLException if a database access error occurs, ! * this method is called on a closed connection or ! * this Connection object is in auto-commit mode * @see commit */ public void rollback() throws SQLException { + if (isClosed()) + throw new PSQLException(GT.tr("Cannot rollback when connection is closed."), + PSQLState.CONNECTION_FAILURE); + if (autoCommit) ! throw new PSQLException(GT.tr("Cannot rollback when autoCommit is enabled."), ! PSQLState.NO_ACTIVE_SQL_TRANSACTION); if (protoConnection.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE) executeTransactionCommand(rollbackQuery);