{@inheritDoc}

@see jp.co.future.uroborosql.client.command.ReplCommand#execute(org.jline.reader.LineReader, java.lang.String[], jp.co.future.uroborosql.config.SqlConfig, java.util.Properties)
963569
@Override
	public boolean execute(final LineReader reader, final String[] parts, final SqlConfig sqlConfig,
			final Properties props) {
		PrintWriter writer = reader.getTerminal().writer();
		if (parts.length >= 2) {
			String sqlName = parts[1].replaceAll("\\.", "/");
			if (sqlConfig.getSqlManager().existSql(sqlName)) {

				try (SqlAgent agent = sqlConfig.agent()) {
					SqlContext ctx = agent.contextFrom(sqlName);
					ctx.setSql(sqlConfig.getSqlManager().getSql(ctx.getSqlName()));
					String[] params = Arrays.copyOfRange(parts, 2, parts.length);
					SqlParamUtils.setSqlParams(ctx, params);
					try {
						int ans = agent.update(ctx);
						agent.commit();
						writer.println("update sql[" + sqlName + "] end. row count=" + ans);
					} catch (ParameterNotFoundRuntimeException | SQLException ex) {
						writer.println("Error : " + ex.getMessage());
						agent.rollback();
					}
				}
			} else {
				writer.println("SQL not found. sql=" + sqlName);
			}
		}
		writer.flush();
		return true;
	}
1340988
private void executeScript(String script) {
        try {
            final StatementSplitter statementSplitter =
                new StatementSplitterResolver(scriptConfigurationInstance.get()).resolve();
            final ScriptExecutor scriptExecutor =
                new ScriptExecutor(databaseConnection.get().getConnection(), scriptConfigurationInstance.get(),
                    statementSplitter);
            scriptExecutor.execute(script);
        } catch (SQLException e) {
            throw new DBUnitConnectionException("Unable to execute script.", e);
        }
    }
423705
public static void executeSQL(final SQLiteDatabase database, String command) {
		// remove comments
		command = command.replaceAll("\\/\\*.*\\*\\/", "");
		command = command.replaceAll("--.*$", "");

		if (command.trim().length() > 0) {
			Logger.info(command);
			database.execSQL(command);
		}

	}
909181
private static void executeAction(InitialContext jndi,
	                                  GuiceApplicationValueContainer config,
	                                  Map<String, String> parameters,
	                                  LiquibaseAction action) throws NamingException, SQLException, LiquibaseException, IOException, ParserConfigurationException
	{
		// Make sure we don't execute any write actions if the database connection is set to read-only
		// N.B. liquibase may create a databasechangeloglock / databasechangelog table if one does not already exist
		if (action.isWriteAction() && StringUtils.equalsIgnoreCase("true", config.getValue(HIBERNATE_IS_READONLY)))
		{
			log.info("Changing liquibase action from " +
			         action +
			         " to ASSERT_UPDATED because hibernate is set to read only mode");
			action = LiquibaseAction.ASSERT_UPDATED;
		}

		// Fail if hbm2ddl is enabled (Hibernate should not be involved in schema management)
		if (StringUtils.isNotEmpty(config.getValue(HIBERNATE_SCHEMA_MANAGEMENT)) && action != LiquibaseAction.GENERATE_CHANGELOG)
		{
			throw new RuntimeException("Liquibase is enabled but so is " +
			                           HIBERNATE_SCHEMA_MANAGEMENT +
			                           ". Only one of these schema management methods may be used at a time.");
		}

		final String dataSourceName = config.getDataSource();
		final String changeLogFile = config.getValue(GuiceProperties.LIQUIBASE_CHANGELOG);
		final String contexts = config.getValue(GuiceProperties.LIQUIBASE_CONTEXTS);
		final String labels = config.getValue(GuiceProperties.LIQUIBASE_LABELS);
		final String defaultSchema = config.getDefaultSchema();

		final String jdbcUrl = config.getValue(AvailableSettings.URL);
		final String jdbcUsername = config.getValue(AvailableSettings.USER);
		final String jdbcPassword = config.getValue(AvailableSettings.PASS);

		if (StringUtils.isEmpty(dataSourceName) && StringUtils.isEmpty(jdbcUrl))
			throw new RuntimeException("Cannot run Liquibase: no JNDI datasource or JDBC URL set");
		else if (changeLogFile == null)
			throw new RuntimeException("Cannot run Liquibase: " + GuiceProperties.LIQUIBASE_CHANGELOG + " is not set");

		int storedTransactionIsolation = Integer.MIN_VALUE;
		Connection connection = null;
		Database database = null;
		try
		{
			// Set up the resource accessor
			final ResourceAccessor resourceAccessor;
			{
				final CompositeResourceAccessor composite;
				{
					ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
					ResourceAccessor threadClFO = new ClassLoaderResourceAccessor(contextClassLoader);

					ResourceAccessor clFO = new ClassLoaderResourceAccessor();

					composite = new CompositeResourceAccessor(clFO, threadClFO);
				}

				// If loading a resource with an absolute path fails, re-try it as a path relative to /
				// This is for unit tests where /liquibase/changelog.xml needs to be accessed as liquibase/changelog.xml
				final ResourceAccessor fallback = new RetryAbsoluteAsRelativeResourceAccessor(composite);

				// Wrap the resource accessor in a filter that interprets ./ as the changeLogFile folder
				resourceAccessor = new RelativePathFilteringResourceAccessor(fallback, changeLogFile);
			}

			// Set up the database
			{
				if (StringUtils.isNotEmpty(dataSourceName))
				{
					if (log.isDebugEnabled())
						log.debug("Look up datasource for liquibase: " + dataSourceName);

					final DataSource dataSource = (DataSource) jndi.lookup(dataSourceName);

					connection = dataSource.getConnection();
				}
				else
				{
					if (log.isDebugEnabled())
						log.debug("Create JDBC Connection directly: " + jdbcUrl);

					// N.B. do we need to call Class.forName on the JDBC Driver URL?
					// JDBC drivers should expose themselves using the service provider interface nowadays so this shouldn't be necessary

					connection = DriverManager.getConnection(jdbcUrl, jdbcUsername, jdbcPassword);
				}

				// Allow changing the transaction isolation away from the default for liquibase
				// This is a hack inserted for SQL Server where the SNAPSHOT isolation is being used
				// because in this mode it refuses to execute certain DDL statements because of metadata not being versioned
				{
					storedTransactionIsolation = connection.getTransactionIsolation();

					// Special-case SQL Server's SNAPSHOT isolation (magic value 4096)
					// In this case we change to READ UNCOMMITTED for the duration of the liquibase run
					if (storedTransactionIsolation == 4096)
					{
						connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
					}
				}

				database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));

				database.setDefaultSchemaName(defaultSchema);
			}

			Liquibase liquibase = new Liquibase(changeLogFile, resourceAccessor, database);


			for (Map.Entry<String, String> param : parameters.entrySet())
			{
				liquibase.setChangeLogParameter(param.getKey(), param.getValue());
			}

			if (log.isDebugEnabled())
				log.debug("Execute liquibase action: " + action);

			switch (action)
			{
				case ASSERT_UPDATED:
					// Figure out which changesets need to be run
					List<ChangeSet> unrun = liquibase.listUnrunChangeSets(new Contexts(contexts), new LabelExpression(labels));

					if (log.isDebugEnabled())
						log.debug("Pending changesets: " + unrun);

					// If any need to be run, fail
					if (unrun.size() > 0)
						throw new LiquibaseChangesetsPending(unrun);
					else
						return;
				case UPDATE:
					// Perform a schema update
					liquibase.update(new Contexts(contexts), new LabelExpression(labels));
					return;
				case MARK_UPDATED:
					// Mark all pending changesets as run
					liquibase.changeLogSync(new Contexts(contexts), new LabelExpression(labels));
					return;
				case GENERATE_CHANGELOG:
					CatalogAndSchema catalogueAndSchema = CatalogAndSchema.DEFAULT;
					DiffToChangeLog writer = new DiffToChangeLog(new DiffOutputControl(false,
					                                                                   false,
					                                                                   false,
					                                                                   new CompareControl.SchemaComparison[0]));

					ByteArrayOutputStream bos = new ByteArrayOutputStream();
					PrintStream pw = new PrintStream(bos);
					liquibase.generateChangeLog(catalogueAndSchema, writer, pw);

					System.out.println("********** GENERATED CHANGELOG START **********");
					System.out.println(new String(bos.toByteArray()));
					System.out.println("********** GENERATED CHANGELOG END **********");
					break;
				default:
					throw new RuntimeException("Unknown liquibase action: " + action);
			}
		}
		finally
		{
			// Restore the transaction isolation value to the Connection (if the previous isolation was known and we changed it).
			// This is just in case the Connection we get is actually a wrapper around a longer-lived Connection whose isolation
			// isn't changed to the desired value when being returned from a connection pool
			// N.B. we don't return to isolations < 0 (isolation at db defaults)
			if (connection != null && connection.getTransactionIsolation() != storedTransactionIsolation && storedTransactionIsolation >= 0)
			{
				connection.setTransactionIsolation(storedTransactionIsolation);
			}

			if (database != null)
				database.close();
			else if (connection != null)
				connection.close();
		}
	}
445481
public void execute(boolean update) {
		if (update) {
			final String sql = getSql().replace("DELETE", "SELECT " + Model._ID);
			final List<T> results = QueryUtils.rawQuery(mTable, sql, getArgs());
			for (T result : results) {
				result.id = null;
			}
		}
		super.execute();
	}
249180
public int[] executeBatch(String sql, Object[]... paramsBatch) throws SQLException {
		Connection conn = null;
		try {
			conn = this.getConnection();
			return SqlExecutor.executeBatch(conn, sql, paramsBatch);
		} catch (SQLException e) {
			throw e;
		} finally {
			this.closeConnection(conn);
		}
	}
120443
@Override
	public final boolean execute() throws SQLException {
		Split split = prepare();
		try {
			return stmt.execute();
		} finally {
			finish(split);
		}
	}
694467
public boolean execute(final String query) throws SQLException {
        startTimer();
        try {
            if (queryResult != null) {
                queryResult.close();
            }
            queryResult = protocol.executeQuery(queryFactory.createQuery(query));
            if (queryResult.getResultSetType() == ResultSetType.SELECT) {
                setResultSet(new DrizzleResultSet(queryResult, this, getProtocol()));
                return true;
            }
            setUpdateCount(((ModifyQueryResult) queryResult).getUpdateCount());
            return false;
        } catch (QueryException e) {
            throw SQLExceptionMapper.get(e);
        } finally {
            stopTimer();
        }
    }
39325
public void execute(String query, Object... params) throws SQLException {
        createPreparedStatement(query, 0, params).execute();
    }
50616
private QueryObservable executeQuery(QueryBuilder queryBuilder) {

    // Raw query properties as default
    String sql = queryBuilder.rawStatement;
    Iterable<String> affectedTables = queryBuilder.rawStatementAffectedTables;

    // If SqlFinishedStatement is set then use that one
    if (queryBuilder.statement != null) {

      SqlCompileable.CompileableStatement compileableStatement =
          queryBuilder.statement.asCompileableStatement();

      sql = compileableStatement.sql;
      affectedTables = compileableStatement.tables;
    }

    // Check for auto update
    if (!queryBuilder.autoUpdate || affectedTables == null) {
      affectedTables = Collections.emptySet();
    }

    return db.createQuery(affectedTables, sql, queryBuilder.args);
  }
881759
@Override
	public final ResultSet executeQuery(String sql) throws SQLException {
		Split s = prepare(sql);
		try {
			return new SimonResultSet(stmt.executeQuery(sql), this, prefix, s.getStopwatch().getName());
		} finally {
			finish(s);
		}
	}
812548
ResultSet executeQueryInternal(
      String sql,
      Map<String, ParameterBindingDTO> parameterBindings)
  throws SQLException
  {
    SFBaseResultSet sfResultSet;
    try
    {
      sfResultSet = sfStatement.execute(sql, parameterBindings,
                                        SFStatement.CallingMethod.EXECUTE_QUERY);
      sfResultSet.setSession(this.connection.getSfSession());
    }
    catch (SFException ex)
    {
      throw new SnowflakeSQLException(ex.getCause(),
                                      ex.getSqlState(), ex.getVendorCode(), ex.getParams());
    }

    if (resultSet != null)
    {
      openResultSets.add(resultSet);
    }
    resultSet = new SnowflakeResultSetV1(sfResultSet, this);

    return getResultSet();
  }
760020
@Override
    public boolean execute(String sql) throws SQLException
    {
        checkClosed();
        VoltSQL query = VoltSQL.parseSQL(sql);
        return this.execute(query);
    }
671890
public static int execute(Connection conn, String sql, Object... params) throws SQLException {
		PreparedStatement ps = null;
		try {
			ps = StatementUtil.prepareStatement(conn, sql, params);
			return ps.executeUpdate();
		} finally {
			DbUtil.close(ps);
		}
	}
272138
public void runSql( String sql ) throws Exception {
        String[] sqlSplit = sql.split("\n");
        StringBuilder sb = new StringBuilder();
        for( String string : sqlSplit ) {
            String trim = string.trim();
            if (trim.length() == 0) {
                continue;
            }
            if (trim.startsWith("--")) {
                continue;
            }
            sb.append(trim + " ");
        }

        String[] sqls = sb.toString().split(";");
        for( String single : sqls ) {
            executeInsertUpdateDeleteSql(single);
        }
    }
244719
public void execute(String statement) throws SQLException {
		if (logger.isDebugEnabled()) {
			logger.debug("Executing SQL statement [" + statement + "]");
		}
		
		Connection connection = null;
		Statement stm = null;
		
		try{
			connection = ds.getConnection();
			stm = connection.createStatement();			
			stm.execute(statement);
		} catch (SQLException e) {
			throw e;
		}finally{
			if(stm!=null) stm.close();
			if(connection!=null) connection.close();			
		}
				
	}
647453
private void executeJdbcStatements(Connection connection, String configName, String statements, String description) {
        Statement stmt = createStatement(configName, connection);
        try {
            log.debug("Executing statement [" + description + "]");
            
            List<String> stmtsToExecute = Stream.of(statements.split(";"))
                    .map(String::trim)
                    .filter(s -> s.length() > 0)
                    .collect(Collectors.toList());
            
            if ( log.isTraceEnabled()) {
                log.trace("These statements will be executed:");
                stmtsToExecute.forEach(s -> log.trace("Statement: [" + s + "]"));
            }
            
            for ( String currentStatement : stmtsToExecute) {
                stmt.execute(currentStatement);
                log.trace("Executing statement: " + currentStatement + " OK!");
            }
            
        } catch (SQLException e) {
            throw new ChorusException(
                    String.format("Failed while executing statement [%s] on database + %s [%s]", description, configName, e.toString(), e)
            );
        }
    }