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

Method executeInsert

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

Executes the given SQL statement (typically an INSERT statement). Use this variant when you want to receive the values of any auto-generated columns, such as an autoincrement ID field. See #executeInsert(GString) for more details. Resource handling is performed automatically where approp

(String sql)

Source from the content-addressed store, hash-verified

3051 * @throws SQLException if a database access error occurs
3052 */
3053 public List<List<Object>> executeInsert(String sql) throws SQLException {
3054 Connection connection = createConnection();
3055 Statement statement = null;
3056 try {
3057 statement = getStatement(connection, sql);
3058 this.updateCount = statement.executeUpdate(sql, Statement.RETURN_GENERATED_KEYS);
3059 ResultSet keys = statement.getGeneratedKeys();
3060 cleanup(statement);
3061 return calculateKeys(keys);
3062 } catch (SQLException e) {
3063 LOG.warning("Failed to execute: " + sql + " because: " + e.getMessage());
3064 throw e;
3065 } finally {
3066 closeResources(connection, statement);
3067 }
3068 }
3069
3070 /**
3071 * Executes the given SQL statement (typically an INSERT statement).

Callers

nothing calls this directly

Calls 12

createConnectionMethod · 0.95
getStatementMethod · 0.95
cleanupMethod · 0.95
calculateKeysMethod · 0.95
closeResourcesMethod · 0.95
getPreparedStatementMethod · 0.95
asListMethod · 0.95
singletonListMethod · 0.95
getParametersMethod · 0.95
asSqlMethod · 0.95
executeUpdateMethod · 0.80
getMessageMethod · 0.45

Tested by

no test coverage detected