private Connection c;
- private HashMap<String, PreparedStatement> statements = new HashMap<String, PreparedStatement>();
+ private HashMap<String, GigiPreparedStatement> statements = new HashMap<String, GigiPreparedStatement>();
private static Properties credentials;
}
}
- public PreparedStatement prepare(String query) throws SQLException {
+ public GigiPreparedStatement prepare(String query) {
ensureOpen();
- PreparedStatement statement = statements.get(query);
+ GigiPreparedStatement statement = statements.get(query);
if (statement == null) {
- statement = c.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
+ try {
+ statement = new GigiPreparedStatement(c.prepareStatement(query, Statement.RETURN_GENERATED_KEYS));
+ } catch (SQLException e) {
+ throw new Error(e);
+ }
statements.put(query, statement);
}
return statement;
lastAction = System.currentTimeMillis();
}
- public static int lastInsertId(PreparedStatement query) throws SQLException {
- ResultSet rs = query.getGeneratedKeys();
- rs.next();
- int id = rs.getInt(1);
- rs.close();
- return id;
- }
-
private static ThreadLocal<DatabaseConnection> instances = new ThreadLocal<DatabaseConnection>() {
@Override