comparison 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
comparison
equal deleted inserted replaced
4085:067341e86375 4086:ee0c60757a94
9 import javax.xml.xpath.XPathConstants; 9 import javax.xml.xpath.XPathConstants;
10 10
11 import java.sql.Connection; 11 import java.sql.Connection;
12 import java.sql.SQLException; 12 import java.sql.SQLException;
13 import java.sql.DriverManager; 13 import java.sql.DriverManager;
14 import java.sql.DatabaseMetaData;
14 15
15 import org.apache.log4j.Logger; 16 import org.apache.log4j.Logger;
16 17
17 public class ConnectionBuilder 18 public class ConnectionBuilder
18 { 19 {
64 catch (ClassNotFoundException cnfe) { 65 catch (ClassNotFoundException cnfe) {
65 throw new SQLException(cnfe); 66 throw new SQLException(cnfe);
66 } 67 }
67 } 68 }
68 69
69 return DriverManager.getConnection(url, user, password); 70 Connection connection =
71 DriverManager.getConnection(url, user, password);
72
73 connection.setAutoCommit(false);
74
75 DatabaseMetaData metaData = connection.getMetaData();
76
77 if (metaData.supportsTransactionIsolationLevel(
78 Connection.TRANSACTION_READ_UNCOMMITTED)) {
79 connection.setTransactionIsolation(
80 Connection.TRANSACTION_READ_UNCOMMITTED);
81 }
82
83 return connection;
70 } 84 }
71 85
72 public ConnectedStatements getConnectedStatements() throws SQLException { 86 public ConnectedStatements getConnectedStatements() throws SQLException {
73 return new ConnectedStatements( 87 return new ConnectedStatements(
74 getConnection(), 88 getConnection(),

http://dive4elements.wald.intevation.org