diff flys-aft/src/main/java/de/intevation/db/ConnectionBuilder.java @ 4086:ee0c60757a94

Added transaction support flys-aft/trunk@3566 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 02 Jan 2012 15:13:58 +0000
parents 100c4e0a45e1
children f939e1e6cfa4
line wrap: on
line diff
--- a/flys-aft/src/main/java/de/intevation/db/ConnectionBuilder.java	Thu Dec 22 12:07:29 2011 +0000
+++ b/flys-aft/src/main/java/de/intevation/db/ConnectionBuilder.java	Mon Jan 02 15:13:58 2012 +0000
@@ -11,6 +11,7 @@
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.DriverManager;
+import java.sql.DatabaseMetaData;
 
 import org.apache.log4j.Logger;
 
@@ -66,7 +67,20 @@
             }
         }
 
-        return DriverManager.getConnection(url, user, password);
+        Connection connection =
+            DriverManager.getConnection(url, user, password);
+
+        connection.setAutoCommit(false);
+
+        DatabaseMetaData metaData = connection.getMetaData();
+
+        if (metaData.supportsTransactionIsolationLevel(
+            Connection.TRANSACTION_READ_UNCOMMITTED)) {
+            connection.setTransactionIsolation(
+                Connection.TRANSACTION_READ_UNCOMMITTED);
+        }
+
+        return connection;
     }
 
     public ConnectedStatements getConnectedStatements() throws SQLException {

http://dive4elements.wald.intevation.org