Executes the given piece of SQL. Also saves the updateCount, if any, for subsequent examination. Example usages: sql.execute "DROP TABLE IF EXISTS person" sql.execute """ CREATE TABLE person ( id INTEGER NOT NULL, firstname VARCHAR(100), lastname VARCHAR(100),
(String sql)
| 2636 | * @throws SQLException if a database access error occurs |
| 2637 | */ |
| 2638 | public boolean execute(String sql) throws SQLException { |
| 2639 | Connection connection = createConnection(); |
| 2640 | Statement statement = null; |
| 2641 | try { |
| 2642 | statement = getStatement(connection, sql); |
| 2643 | boolean isResultSet = statement.execute(sql); |
| 2644 | this.updateCount = statement.getUpdateCount(); |
| 2645 | cleanup(statement); |
| 2646 | return isResultSet; |
| 2647 | } catch (SQLException e) { |
| 2648 | LOG.warning("Failed to execute: " + sql + " because: " + e.getMessage()); |
| 2649 | throw e; |
| 2650 | } finally { |
| 2651 | closeResources(connection, statement); |
| 2652 | } |
| 2653 | } |
| 2654 | |
| 2655 | /** |
| 2656 | * Executes the given piece of SQL. |