Execute script on database. Set auto commit mode if needed.

@param scripts
the scripts for execution
@throws SQLException
331888
protected void execute(List<String> scripts) throws SQLException
   {
      SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);

      // set needed auto commit mode
      boolean autoCommit = connection.getAutoCommit();
      if (autoCommit != this.autoCommit)
      {
         connection.setAutoCommit(this.autoCommit);
      }

      Statement st = connection.createStatement();
      try
      {
         for (String scr : scripts)
         {
            String sql = JDBCUtils.cleanWhitespaces(scr.trim());
            if (!sql.isEmpty())
            {
               if (LOG.isDebugEnabled())
               {
                  LOG.debug("Execute script: \n[" + sql + "]");
               }

               executeQuery(st, sql);
            }
         }
      }
      finally
      {
         try
         {
            st.close();
         }
         catch (SQLException e)
         {
            LOG.error("Can't close the Statement." + e.getMessage());
         }

         // restore previous auto commit mode
         if (autoCommit != this.autoCommit)
         {
            connection.setAutoCommit(autoCommit);
         }
      }
   }
261195
private void createTables() throws SQLException, BlockStoreException {
        Statement s = conn.get().createStatement();
        // create all the database tables
        for (String sql : getCreateTablesSQL()) {
            if (log.isDebugEnabled()) {
                log.debug("DatabaseFullPrunedBlockStore : CREATE table [SQL= {0}]", sql);
            }
            s.executeUpdate(sql);
        }
        // create all the database indexes
        for (String sql : getCreateIndexesSQL()) {
            if (log.isDebugEnabled()) {
                log.debug("DatabaseFullPrunedBlockStore : CREATE index [SQL= {0}]", sql);
            }
            s.executeUpdate(sql);
        }
        s.close();

        // insert the initial settings for this store
        PreparedStatement ps = conn.get().prepareStatement(getInsertSettingsSQL());
        ps.setString(1, CHAIN_HEAD_SETTING);
        ps.setNull(2, Types.BINARY);
        ps.execute();
        ps.setString(1, VERIFIED_CHAIN_HEAD_SETTING);
        ps.setNull(2, Types.BINARY);
        ps.execute();
        ps.setString(1, VERSION_SETTING);
        ps.setBytes(2, "03".getBytes());
        ps.execute();
        ps.close();
        createNewStore(params);
    }
633447
public void commit() throws DBException
    {
        super.commit();   // Will throw an error if something is not set up right.
        try   {
            if (this.getRemoteDatabase() != null)
            {
                synchronized (this.getSyncObject(this.getRemoteDatabase()))
                {
                    this.getRemoteDatabase().commit();
                }
            }
        } catch (RemoteException ex)    {
            Utility.getLogger().warning("Remote commit error: " + ex.getMessage());
            ex.printStackTrace();
        } catch (Exception ex)  {
            throw this.convertError(ex);
        }
    }
724883
public static void executeScriptResources( File scriptsDir ) throws IOException {

		if( scriptsDir.isDirectory()) {
			List<File> scriptFiles = Utils.listAllFiles( scriptsDir );
			Logger logger = Logger.getLogger( AgentUtils.class.getName());

			for( File script : scriptFiles) {
				if( script.getName().contains( Constants.SCOPED_SCRIPT_AT_AGENT_SUFFIX )) {
					script.setExecutable( true );
					String[] command = { script.getAbsolutePath()};
					try {
						ProgramUtils.executeCommand( logger, command, script.getParentFile(), null, null, null );

					} catch( InterruptedException e ) {
						Utils.logException( logger, e );
					}
				}
			}
		}
	}
223357
public void finish() throws SQLException{
		Statement statement = connection.createStatement();
		statement.execute("CREATE INDEX articleIdx on revisions(ArticleID);");
		statement.close();
		statement = connection.createStatement();
		statement.execute("ALTER TABLE index_articleID_rc_ts ENABLE KEYS;");
		statement.close();
		statement = connection.createStatement();
		statement.execute("ALTER TABLE index_revisionID ENABLE KEYS;");
		statement.close();
		statement = connection.createStatement();
		statement.execute("ALTER TABLE index_chronological ENABLE KEYS;");
		statement.close();
	}
760020
@Override
    public boolean execute(String sql) throws SQLException
    {
        checkClosed();
        VoltSQL query = VoltSQL.parseSQL(sql);
        return this.execute(query);
    }
649516
public static void execute(final Connection connection, final String sql) throws SQLException {
        try (PreparedStatement preparedStatement = connection.prepareStatement(sql)){
            preparedStatement.execute();
        }
    }
1018019
private void executeStatement(String statement) throws SQLException {

        Statement stmt = null;

        try {
            stmt = m_con.createStatement();
            stmt.execute(statement);
        } finally {
            if (stmt != null) {
                stmt.close();
            }
        }
    }
510122
private void executeStatement(String statement) throws SQLException {
		logger.entering(CLASSNAME, "executeStatement", statement);

		Connection conn = getConnection();
		PreparedStatement ps = null;

		ps = conn.prepareStatement(statement);
		ps.executeUpdate();

		cleanupConnection(conn, ps);
		logger.exiting(CLASSNAME, "executeStatement");
	}
314981
private static void executeSqlScript(Connection connection, URL scriptUrl) throws SQLException {
        for (String sqlStatement : readSqlStatements(scriptUrl)) {
            if (!sqlStatement.trim().isEmpty()) {
                connection.prepareStatement(sqlStatement).executeUpdate();
            }
        }
    }
1221375
def db_exec_and_commit(self, sql: str, *args) -> int:
        """"""
        rowcount = self.db_exec(sql, *args)
        self.commit()
        return rowcount
775064
@Override
    public boolean execute() throws SQLException {
        boolean isOk = false;

        try {
            boolean result = internalStmt.execute();
            isOk = true;

            return result;
        } finally {
            poolableConn.updateLastSQLExecutionTime(isOk);
        }
    }
161751
public int executeUpdate(Connection conn, DataObject[] objects) throws SQLException {
        PreparedStatement statement = conn.prepareStatement(_sql);
        try {
            for (DataObject object: objects) {
                load(statement, object);
                statement.addBatch();
            }
            int count = getAffectedRowCount(statement.executeBatch());
            return count;
        } finally {
            statement.close();
        }
    }
249851
static ResultSet executeStatement(SQL sql) throws SQLException {
    try (SqlSession session = sqlSessionFactory.openSession(true)) {
      try (Connection conn = session.getConnection()) {
        try (Statement stmt = conn.createStatement()) {
          return stmt.executeQuery(sql.toString());
        }
      }
    }
  }
987762
def script(self, sql_script, split_algo='sql_split', prep_statements=True, dump_fails=True):
        """"""
        return Execute(sql_script, split_algo, prep_statements, dump_fails, self)
1109701
public void execute(Runnable statements)
	{
		try (HibernateTransaction tx = start().withAutoRollback())
		{
			statements.run();

			// Success, perform a TX commit
			tx.commit();
		}
	}
1358945
protected void executeScript(final String filename, final Statement statement) throws SQLException {
        LOG.info("Executing sql script: " + filename);

        InputStream fileInputStream;
        try {
            fileInputStream = ConfigurationLoader.loadResource(filename);
        } catch (FileNotFoundException e) {
            LOG.error("could not execute script", e);
            return;
        }

        final BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream));
        executeScript(reader, statement);
    }