diff options
author | Caspar De Groot | 2011-03-01 08:03:08 +0000 |
---|---|---|
committer | Caspar De Groot | 2011-03-01 08:03:08 +0000 |
commit | d811c1d1af82a8c87fadcb144835a9c31b5c029f (patch) | |
tree | 117acbe567a3f98efa8673a4ac0682907ab3ecf6 | |
parent | d4bcd3a6ff2e355964b85134dcf9c7a4c93a170a (diff) | |
download | cdo-d811c1d1af82a8c87fadcb144835a9c31b5c029f.tar.gz cdo-d811c1d1af82a8c87fadcb144835a9c31b5c029f.tar.xz cdo-d811c1d1af82a8c87fadcb144835a9c31b5c029f.zip |
[Bug 336932] [DB] Derby connection is not closed
https://bugs.eclipse.org/bugs/show_bug.cgi?id=336932
-rw-r--r-- | plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java index caccac1a63..d45c868cd2 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java @@ -180,7 +180,13 @@ public final class DBUtil { try { - rollback(connection); + // Only for connections with autoCommit = false, we try a rollback + // first to clear any open transactions. + if (!connection.getAutoCommit()) + { + rollback(connection); + } + connection.close(); } catch (Exception ex) @@ -550,18 +556,18 @@ public final class DBUtil { trace(stmt.toString()); int result = stmt.executeUpdate(); - + // basic check of update result if (exactlyOne && result != 1) { throw new IllegalStateException(stmt.toString() + " returned Update count " + result + " (expected: 1)"); //$NON-NLS-1$ //$NON-NLS-2$ } - + if (result == Statement.EXECUTE_FAILED) { throw new IllegalStateException(stmt.toString() + " returned EXECUTE_FAILED"); //$NON-NLS-1$ } - + return result; } |