/** * Convenience wrapper to manage the boilerplate when performing unsafe operations. * * @param <T> The type of thing to return. * @param sql The sql to perform this operation. * @param operation The operation to perform with the prepared statement. * @return A T of some kind * @throws SQLException if there is a problem running the query. */ public <T> T performUnsafeOperation(final String sql, SQLOperation<T> operation) throws SQLException { Connection con = null; PreparedStatement stm = null; T retval; try { con = getConnection(); stm = con.prepareStatement(sql); retval = operation.run(stm); return retval; } finally { if (stm != null) { stm.close(); } releaseConnection(con); } }
/** * Convenience wrapper to manage the boilerplate when performing unsafe operations. * * @param <T> The type of thing to return. * @param sql The sql to perform this operation. * @param operation The operation to perform with the prepared statement. * @return A T of some kind * @throws SQLException if there is a problem running the query. */ public <T> T performUnsafeOperation(final String sql, SQLOperation<T> operation) throws SQLException { Connection con = null; PreparedStatement stm = null; T retval; try { con = getConnection(); stm = con.prepareStatement(sql); retval = operation.run(stm); return retval; } finally { if (stm != null) { stm.close(); } releaseConnection(con); } }