-
Notifications
You must be signed in to change notification settings - Fork 231
Open
Labels
Description
sql2o 1.5.2 and 1.5.4
If using beginTransaction and createQuery without explicit closing, commit with closeConnection=true will leak statements when using pooled connections.
I'm using Oracle and get "ORA-01000: maximum open cursors exceeded"
The problem is that Connection.commit(true) uses closeJdbcConnection() instead of close() which would have closed Statements before closing connection.
Example:
def insertPersistentReprList(dtoList: Seq[JournalEntryDto]) {
val sql = "insert into ...."
// Insert the whole list in one transaction
val c = sql2o.beginTransaction()
try {
dtoList.foreach {
dto =>
val insert = c.createQuery(sql)
try {
insert.addParameter("field", "value").executeUpdate
} finally {
// Without this statement-close, we would leak statements resulting in ORA-01000: maximum open cursors exceeded
insert.close()
}
}
// All inserts executed - commit transaction
c.commit(true)
} catch {
case e:Throwable =>
c.rollback(true)
throw e
}
}