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)
| 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). |
nothing calls this directly
no test coverage detected