Embedded Derby - java.sql.SQLException: Cannot close a connection while a transaction is still active.

Hi,


I’m experiencing this, but with v2.0.1 and Derby v10.8.1.2:


http://forum.liquibase.org/#topic/49382000000030147


I’m running Liquibase from my java app and have it set up similar to the suggestion here:


http://forum.liquibase.org/#topic/49382000000033203


However, I’m not calling connection.rollback() before connection.close().  Calling connection.rollback() gets rid of the error, but I don’t understand why it’s needed or what effect it’s going to have (is it going to rollback an important transaction?).


I get the error without any changesets running.  I don’t get the error when I switch to the maven plugin instead of my own code.  The SpringLiquibase class in the integration package does connection.getAutoCommit() and a rollback if it returns false.  I tried setting connection.setAutoCommit(true) in my code, but it doesn’t make any difference.


I found this old mailing list thread that might hint at the underlying cause:


http://old.nabble.com/commit-and-close-needs-specific-ordering—td18153351.html


Any suggestions?  I can post my code or even do a quick sample project if it helps.  Just ask.


Ryan

Sorry for the slow reply. If you could post a sample project to expose the issue, that would be great


Nathan

Ok.  Here’s a simple sample project.  Run ‘mvn clean test’.  Ii will execute 2 test classes (maybe not the best use of tests, but the easiest for me).  Each test is forked.  Each one creates an in memory derby database and runs Liquibase against it.  The only difference between the two is calling connection.rollback() before connection.close().  It’s line 75 of the DatabaseUpdater class.


WithoutRollback40Test should throw the exception I’m talking about.

Thanks for the example project, that’s a big help. I created http://liquibase.jira.com/browse/CORE-1034 to track the bug.


Nathan