/** * Execute the given schema script on the given JDBC Connection. * * <p>Note that the default implementation will log unsuccessful statements and continue to * execute. Override the {@code executeSchemaStatement} method to treat failures differently. * * @param con the JDBC Connection to execute the script on * @param sql the SQL statements to execute * @throws SQLException if thrown by JDBC methods * @see #executeSchemaStatement */ protected void executeSchemaScript(Connection con, String[] sql) throws SQLException { if (sql != null && sql.length > 0) { boolean oldAutoCommit = con.getAutoCommit(); if (!oldAutoCommit) { con.setAutoCommit(true); } try { Statement stmt = con.createStatement(); try { for (String sqlStmt : sql) { executeSchemaStatement(stmt, sqlStmt); } } finally { JdbcUtils.closeStatement(stmt); } } finally { if (!oldAutoCommit) { con.setAutoCommit(false); } } } }