--- a/src/Pure/General/sql.scala Fri Feb 10 11:04:28 2017 +0100
+++ b/src/Pure/General/sql.scala Fri Feb 10 11:15:52 2017 +0100
@@ -173,15 +173,16 @@
def transaction[A](body: => A): A =
{
val auto_commit = connection.getAutoCommit
- val savepoint = connection.setSavepoint
-
try {
connection.setAutoCommit(false)
- val result = body
- connection.commit
- result
+ val savepoint = connection.setSavepoint
+ try {
+ val result = body
+ connection.commit
+ result
+ }
+ catch { case exn: Throwable => connection.rollback(savepoint); throw exn }
}
- catch { case exn: Throwable => connection.rollback(savepoint); throw exn }
finally { connection.setAutoCommit(auto_commit) }
}
@@ -208,6 +209,7 @@
{ stmt.setBinaryStream(i, bytes.stream(), bytes.length) }
def set_date(stmt: PreparedStatement, i: Int, date: Date)
+
/* output */
def bool(rs: ResultSet, name: String): Boolean = rs.getBoolean(name)