Skip to content

Commit

Permalink
GROOVY-11469: Empty execute method in groovy.sql.Sql
Browse files Browse the repository at this point in the history
  • Loading branch information
paulk-asert committed Sep 5, 2024
1 parent a2e8460 commit 0336980
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
Original file line number Diff line number Diff line change
Expand Up @@ -2512,32 +2512,7 @@ public boolean execute(String sql, List<Object> params) throws SQLException {
* @since 2.3.2
*/
public void execute(String sql, List<Object> params, @ClosureParams(value=FromString.class, options={"boolean,java.util.List<groovy.sql.GroovyRowResult>", "boolean,int"}) Closure resultClosure) throws SQLException {
Connection connection = createConnection();
PreparedStatement statement = null;
try {
statement = getPreparedStatement(connection, sql, params);
boolean isResultSet = statement.execute();
int updateCount = statement.getUpdateCount();
while(isResultSet || updateCount != -1) {
if (resultClosure.getMaximumNumberOfParameters() != 2) {
throw new SQLException("Incorrect number of parameters for resultClosure");
}
if (isResultSet) {
ResultSet resultSet = statement.getResultSet();
List<GroovyRowResult> rowResult = resultSet == null ? null : asList(sql, resultSet);
resultClosure.call(isResultSet, rowResult);
} else {
resultClosure.call(isResultSet, updateCount);
}
isResultSet = statement.getMoreResults();
updateCount = statement.getUpdateCount();
}
} catch (SQLException e) {
LOG.warning("Failed to execute: " + sql + " because: " + e.getMessage());
throw e;
} finally {
closeResources(connection, statement);
}
execute(sql, params, null, resultClosure);
}

/**
Expand Down

0 comments on commit 0336980

Please sign in to comment.