Performs the given SQL query, which should return a single ResultSet object. The given closure is called with the ResultSet as its argument. Example usages: sql.query("select from PERSON where firstname like 'S%'") { ResultSet rs -> while (rs.next()) p
(String sql, @ClosureParams(value=SimpleType.class, options="java.sql.ResultSet") Closure closure)
| 1284 | * @throws SQLException if a database access error occurs |
| 1285 | */ |
| 1286 | public void query(String sql, @ClosureParams(value=SimpleType.class, options="java.sql.ResultSet") Closure closure) throws SQLException { |
| 1287 | Connection connection = createConnection(); |
| 1288 | Statement statement = null; |
| 1289 | ResultSet results = null; |
| 1290 | try { |
| 1291 | statement = getStatement(connection, sql); |
| 1292 | results = statement.executeQuery(sql); |
| 1293 | closure.call(results); |
| 1294 | cleanup(statement); |
| 1295 | } catch (SQLException e) { |
| 1296 | LOG.warning("Failed to execute: " + sql + " because: " + e.getMessage()); |
| 1297 | throw e; |
| 1298 | } finally { |
| 1299 | closeResources(connection, statement, results); |
| 1300 | } |
| 1301 | } |
| 1302 | |
| 1303 | /** |
| 1304 | * Performs the given SQL query, which should return a single |
nothing calls this directly
no test coverage detected