MCPcopy Index your code
hub / github.com/apache/groovy / query

Method query

subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java:1286–1301  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

createConnectionMethod · 0.95
getStatementMethod · 0.95
cleanupMethod · 0.95
closeResourcesMethod · 0.95
getPreparedStatementMethod · 0.95
singletonListMethod · 0.95
getParametersMethod · 0.95
asSqlMethod · 0.95
executeQueryMethod · 0.80
callMethod · 0.65
getMessageMethod · 0.45

Tested by

no test coverage detected