Mercurial > dive4elements > river
view flys-aft/src/main/java/de/intevation/db/ConnectedStatements.java @ 4077:97de7a552b79
Load DIPS XML
flys-aft/trunk@3452 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 16 Dec 2011 16:21:59 +0000 |
parents | 100c4e0a45e1 |
children | ee0c60757a94 |
line wrap: on
line source
package de.intevation.db; import java.util.HashMap; import java.util.Map; import java.sql.Connection; import java.sql.SQLException; public class ConnectedStatements { protected Connection connection; protected Map<String, SymbolicStatement> statements; protected Map<String, SymbolicStatement.Instance> boundStatements; public ConnectedStatements( Connection connection, Map<String, SymbolicStatement> statements ) { this.connection = connection; this.statements = statements; boundStatements = new HashMap<String, SymbolicStatement.Instance>(); } public SymbolicStatement.Instance getStatement(String key) throws SQLException { SymbolicStatement.Instance stmnt = boundStatements.get(key); if (stmnt != null) { return stmnt; } SymbolicStatement ss = statements.get(key); if (ss == null) { return null; } stmnt = ss.new Instance(connection); boundStatements.put(key, stmnt); return stmnt; } public void close() { for (SymbolicStatement.Instance s: boundStatements.values()) { s.close(); } try { connection.close(); } catch (SQLException sqle) { } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :