Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 25890 invoked from network); 2 Jul 2007 14:16:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jul 2007 14:16:29 -0000 Received: (qmail 85132 invoked by uid 500); 2 Jul 2007 14:16:29 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 85107 invoked by uid 500); 2 Jul 2007 14:16:28 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 85097 invoked by uid 99); 2 Jul 2007 14:16:28 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jul 2007 07:16:28 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jul 2007 07:16:25 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id CD6ED714191 for ; Mon, 2 Jul 2007 07:16:04 -0700 (PDT) Message-ID: <5187779.1183385764836.JavaMail.jira@brutus> Date: Mon, 2 Jul 2007 07:16:04 -0700 (PDT) From: "Bill Robertson (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Closed: (DERBY-2886) Close autocommit(false) connection causes exception with code 25000 when no transaction is pending In-Reply-To: <3856507.1183223944914.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-2886?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Bill Robertson closed DERBY-2886. --------------------------------- Resolution: Won't Fix Not a bug > Close autocommit(false) connection causes exception with code 25000 when no transaction is pending > -------------------------------------------------------------------------------------------------- > > Key: DERBY-2886 > URL: https://issues.apache.org/jira/browse/DERBY-2886 > Project: Derby > Issue Type: Bug > Components: JDBC > Affects Versions: 10.2.1.6, 10.2.2.0 > Environment: Java 5 and Java 6 > Embedded Driver > Win XP > Reporter: Bill Robertson > > I have a simple program to demonstrate this. The interesting part creates a new connection, sets autocommit(false), executes a query, and the closes the connection. This generates an exception with result code 25000 and a message "Invalid transaction state." every time. According to the docs that I could find, that means that you're trying to close a connection with a pending transaction. However, there is no pending transaction because no inserts/updates/deletes/creates/drops etc. have been issued on the connection. > So far, I have found a work around. If I set autocommit(true) before closing, I can close the connection without error. I'm not sure what the possible side effects of this are though. > I'm not sure if I will be able to attach the test program, so here it is. Also included is sample output of it running under derby 10.2.1.6 and 10.2.2.0 in Java5 and Java 6. > ----- TestBoom.java ---------------------------------------------------- > import java.sql.*; > import org.apache.derby.jdbc.EmbeddedDriver; > public class TestBoom { > public static void main(String[] args) throws Exception { > > // register driver > EmbeddedDriver registerMe = new EmbeddedDriver(); > // create a datbase with a table that has one row > Connection conn = DriverManager.getConnection("jdbc:derby:foo;create=true"); > Statement s=conn.createStatement(); > s.executeUpdate("create table foo(foo int)"); > s.close(); > s = conn.createStatement(); > s.executeUpdate("insert into foo values (1)"); > s.close(); > conn.close(); > // create a connection, disable autocommit, issue a query and > // close the connection > conn = DriverManager.getConnection("jdbc:derby:foo"); > conn.setAutoCommit(false); > PreparedStatement ps = conn.prepareStatement("select foo from foo where foo = 1"); > ResultSet rs = ps.executeQuery(); > if(rs.next()) { > System.out.println(rs.getInt(1)); > } > rs.close(); > ps.close(); > // conn.setAutoCommit(true); // uncomment this line and the close will not throw > conn.close(); //boom > } > } > ------------------------------------------------------------------------------- > ----- Output (derby 10.2.1.6 & 10.2.2.0, Java 5 & Java 6) ---- > ***** Derby 10.2.1.6, Java 6 ***** > set path=c:\jdk1.6.0_01\bin;%path% > set classpath=.;db-derby-10.2.1.6-bin\lib\derby.jar > javac TestBoom.java > java TestBoom > 1 > Exception in thread "main" java.sql.SQLException: Invalid transaction state. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.close(Unknown Source) > at TestBoom.main(TestBoom.java:30) > rd /q/s foo > ***** Derby 10.2.2.0, Java 6 ***** > set classpath=.;db-derby-10.2.2.0-bin\lib\derby.jar > javac TestBoom.java > java TestBoom > 1 > Exception in thread "main" java.sql.SQLException: Invalid transaction state. > at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.close(Unknown Source) > at TestBoom.main(TestBoom.java:30) > Caused by: java.sql.SQLException: Invalid transaction state. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source) > ... 7 more > ***** Derby 10.2.1.6, Java 5 ***** > set path=c:\jdk1.5.0_12\bin;%path% > set classpath=.;db-derby-10.2.1.6-bin\lib\derby.jar > javac TestBoom.java > rd /q/s foo > java TestBoom > 1 > Exception in thread "main" java.sql.SQLException: Invalid transaction state. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.close(Unknown Source) > at TestBoom.main(TestBoom.java:30) > ***** Derby 10.2.2.0, Java 5 ***** > set classpath=.;db-derby-10.2.2.0-bin\lib\derby.jar > rd /q/s foo > javac TestBoom.java > java TestBoom > 1 > Exception in thread "main" java.sql.SQLException: Invalid transaction state. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.close(Unknown Source) > at TestBoom.main(TestBoom.java:30) > ------------------------------------------------------------------------------- -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.