Mercurial > dive4elements > river
diff flys-aft/src/main/java/de/intevation/db/ConnectedStatements.java @ 4087:aad1886ea226
Store new gauges in FLYS db.
flys-aft/trunk@3568 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 02 Jan 2012 17:45:25 +0000 |
parents | ee0c60757a94 |
children | b195fede1c3b |
line wrap: on
line diff
--- a/flys-aft/src/main/java/de/intevation/db/ConnectedStatements.java Mon Jan 02 15:13:58 2012 +0000 +++ b/flys-aft/src/main/java/de/intevation/db/ConnectedStatements.java Mon Jan 02 17:45:25 2012 +0000 @@ -8,9 +8,14 @@ import java.sql.Connection; import java.sql.SQLException; import java.sql.Savepoint; +import java.sql.DatabaseMetaData; + +import org.apache.log4j.Logger; public class ConnectedStatements { + private static Logger log = Logger.getLogger(ConnectedStatements.class); + protected Connection connection; protected Map<String, SymbolicStatement> statements; @@ -33,9 +38,16 @@ } protected void checkSavePoints() throws SQLException { - if (connection.getMetaData().supportsSavepoints()) { + DatabaseMetaData metaData = connection.getMetaData(); + if (metaData.supportsSavepoints()) { + log.info("Driver '" + metaData.getDriverName() + + "' does support savepoints."); savepoints = new ArrayDeque<Savepoint>(); } + else { + log.info("Driver '" + metaData.getDriverName() + + "' does not support savepoints."); + } } public SymbolicStatement.Instance getStatement(String key) @@ -56,20 +68,20 @@ return stmnt; } - void beginTransaction() throws SQLException { + public void beginTransaction() throws SQLException { if (savepoints != null) { savepoints.push(connection.setSavepoint()); } } - void commitTransaction() throws SQLException { + public void commitTransaction() throws SQLException { if (savepoints != null) { savepoints.pop(); } connection.commit(); } - void rollbackTransaction() throws SQLException { + public void rollbackTransaction() throws SQLException { if (savepoints != null) { Savepoint savepoint = savepoints.pop(); connection.rollback(savepoint);