Skip to content

Commit a74bba1

Browse files
committed
rollback connection in closeConnectionFully
1 parent e8c042e commit a74bba1

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
@@ -254,6 +254,17 @@ void closeConnectionFully(boolean logErrors) {
254254
Log.warn("Error when closing connection Statements", ex);
255255
}
256256
}
257+
try {
258+
// DB2 (and some other DBMS) may have uncommitted changes and do not allow close
259+
// so try to do a rollback.
260+
if (!connection.getAutoCommit()) {
261+
connection.rollback();
262+
}
263+
} catch (SQLException ex) {
264+
if (logErrors) {
265+
Log.warn("Could not perform rollback", ex);
266+
}
267+
}
257268
try {
258269
connection.close();
259270
pool.dec();

0 commit comments

Comments
 (0)