Skip to content

Commit 674de26

Browse files
authored
Merge pull request #110 from FOCONIS/rollback-on-close-connection-fully
rollback connection in closeConnectionFully
2 parents 2ef90a7 + a74bba1 commit 674de26

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ebean-datasource/src/main/java/io/ebean/datasource/pool/PooledConnection.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,17 @@ void closeConnectionFully(boolean logErrors) {
259259
Log.warn("Error when closing connection Statements", ex);
260260
}
261261
}
262+
try {
263+
// DB2 (and some other DBMS) may have uncommitted changes and do not allow close
264+
// so try to do a rollback.
265+
if (!connection.getAutoCommit()) {
266+
connection.rollback();
267+
}
268+
} catch (SQLException ex) {
269+
if (logErrors) {
270+
Log.warn("Could not perform rollback", ex);
271+
}
272+
}
262273
try {
263274
connection.close();
264275
pool.dec();

0 commit comments

Comments
 (0)