//Get a prepared statement to use PreparedStatement stmnt = null;
try {
//Get an actual prepared statement stmnt = conn.prepareStatement(sql);
//Attempt to stuff this statement with the given values. If //no values were given, then we can skip this step. if(pStmntValues != null) { PreparedStatementFactory.buildStatement(stmnt, pStmntValues); }
//Attempt to execute the statement ResultSet rs = stmnt.executeQuery();
//Get the results from this query Object[] results = processor.process(rs);
//Close out the statement only. The connection will be closed by the //caller. closeStmnt(stmnt);
//Return the results return results;
//Any SQL exceptions that occur should be recast to our runtime query //exception and thrown from here } catch(SQLException e) { String message = "Could not perform the query for " + sql;
//Close out all resources on an exception closeConn(conn); closeStmnt(stmnt);
//And rethrow as our runtime exception throw new DatabaseQueryException(message); } } } ... }