summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2011-03-01 03:03:08 (EST)
committerCaspar De Groot2011-03-01 03:03:08 (EST)
commitd811c1d1af82a8c87fadcb144835a9c31b5c029f (patch)
tree117acbe567a3f98efa8673a4ac0682907ab3ecf6
parentd4bcd3a6ff2e355964b85134dcf9c7a4c93a170a (diff)
downloadcdo-d811c1d1af82a8c87fadcb144835a9c31b5c029f.zip
cdo-d811c1d1af82a8c87fadcb144835a9c31b5c029f.tar.gz
cdo-d811c1d1af82a8c87fadcb144835a9c31b5c029f.tar.bz2
[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.java14
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 caccac1..d45c868 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;
}