Get execute callback.

@param databaseType database type
@param isExceptionThrown is exception thrown
@return execute callback
189202
public static SQLExecuteCallback<Boolean> getPreparedSQLExecuteCallback(final DatabaseType databaseType, final boolean isExceptionThrown) {
        return new SQLExecuteCallback<Boolean>(databaseType, isExceptionThrown) {
            
            @Override
            protected Boolean executeSQL(final RouteUnit routeUnit, final Statement statement, final ConnectionMode connectionMode) throws SQLException {
                return ((PreparedStatement) statement).execute();
            }
        };
    }
682812
public static Method findGetMethod(Field field, DatabaseType databaseType, boolean throwExceptions)
			throws IllegalArgumentException {
		Method fieldGetMethod = findMethodFromNames(field, true, throwExceptions,
				methodFromField(field, "get", databaseType, true), methodFromField(field, "get", databaseType, false),
				methodFromField(field, "is", databaseType, true), methodFromField(field, "is", databaseType, false));
		if (fieldGetMethod == null) {
			return null;
		}
		if (fieldGetMethod.getReturnType() != field.getType()) {
			if (throwExceptions) {
				throw new IllegalArgumentException("Return type of get method " + fieldGetMethod.getName()
						+ " does not return " + field.getType());
			} else {
				return null;
			}
		}
		return fieldGetMethod;
	}
187093
public boolean isNeedRewriteRowCount(final DatabaseType databaseType) {
        return DatabaseType.MySQL == databaseType || DatabaseType.PostgreSQL == databaseType || DatabaseType.H2 == databaseType;
    }
559705
public final void execute()
  {
    _log.debug( _sqlString );

    CallableStatement lCallableStatement = null;

    try
    {
      lCallableStatement = _callableStatementProvider.createCallableStatement( _sqlString );

      useCallableStatement( lCallableStatement );
    }
    catch( SQLException e )
    {
      _log.debug( e + ": " + _sqlString, e );

      throw ExceptionManager.createException( e, _sqlString );
    }
    finally
    {
      if( lCallableStatement != null )
      {
        try
        {
          lCallableStatement.close();
        }
        catch( SQLException e )
        {
          _log.debug( e, e );

          throw ExceptionManager.createException( e, _sqlString );
        }
      }
    }
  }
81881
@Override
  public ResultSet executeQuery(String sql) throws SQLException
  {
    raiseSQLExceptionIfStatementIsClosed();
    return executeQueryInternal(sql, null);
  }
1368451
@Override
  public final int getVersionDatabase() {
    try {
      String query = "select count(*) as TOTALROWS from " + DatabaseInfo.class
        .getSimpleName().toUpperCase() + ";";
      Integer rowCount = evalIntegerResult(query, "TOTALROWS");
      if (rowCount != 1) {
        throw new ExceptionWithCode(ExceptionWithCode.CONFIGURATION_MISTAKE,
          "database_info_config_error");
      }
      query = "select DATABASEVERSION from " + DatabaseInfo.class
        .getSimpleName().toUpperCase() + ";";
      Integer databaseVersion = evalIntegerResult(query, "DATABASEVERSION");
      if (databaseVersion == null) {
        throw new ExceptionWithCode(ExceptionWithCode.CONFIGURATION_MISTAKE,
          "database_info_config_error");
      }
      return databaseVersion;
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
1177307
@Override
	public synchronized List<RecordSessionUrl> getUrlsForType (int type) throws DatabaseException {
    	try {
			psGetAlluRLSForType.setInt(1, type);
			try (ResultSet rs = psGetAlluRLSForType.executeQuery()) {
				List<RecordSessionUrl> result = new ArrayList<>();
				while (rs.next()) {
					result.add(new RecordSessionUrl(rs.getLong(URLID), rs.getInt(TYPE), rs.getString(URL)));
				}
				return result;
			}
		} catch (SQLException e) {
			throw new DatabaseException(e);
		}
    }
1106856
public static String execQueryAllRows(@NotNull final SQLInputs sqlInputs) throws Exception {
        ConnectionService connectionService = new ConnectionService();
        try (final Connection connection = connectionService.setUpConnection(sqlInputs)) {
            connection.setReadOnly(true);

            Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency());

            statement.setQueryTimeout(sqlInputs.getTimeout());
            final ResultSet resultSet = statement.executeQuery(sqlInputs.getSqlCommand());

            final String resultSetToDelimitedColsAndRows = Format.resultSetToDelimitedColsAndRows(resultSet, sqlInputs.isNetcool(), sqlInputs.getColDelimiter(), sqlInputs.getRowDelimiter());
            if (resultSet != null) {
                resultSet.close();
            }
            return resultSetToDelimitedColsAndRows;
        }
    }
427787
public DatabaseException convertError(Exception ex)
    {
        DatabaseException eDB = null;
        int iError = DBConstants.ERROR_RETURN;
        String strMessage = "Error!";
        if (ex != null)
            strMessage = ex.getMessage();
        if (ex instanceof SQLException)
        {
            SQLException sqlex = (SQLException)ex;
            String strState = sqlex.getSQLState();
            strMessage += strState;
            if (!m_bFirstErrorCheck)
            {
                m_bFirstErrorCheck = true;
                m_strFileNotFoundErrorText = (String)this.getProperties().get(SQLParams.TABLE_NOT_FOUND_ERROR_TEXT);
                if (m_strFileNotFoundErrorText != null)
                    m_strFileNotFoundErrorText = m_strFileNotFoundErrorText.toLowerCase();
                m_strFileNotFoundErrorCode = (String)this.getProperties().get(SQLParams.TABLE_NOT_FOUND_ERROR_CODE);
                m_strDBNotFoundErrorText = (String)this.getProperties().get(SQLParams.DB_NOT_FOUND_ERROR_TEXT);
                if (m_strDBNotFoundErrorText != null)
                    m_strDBNotFoundErrorText = m_strDBNotFoundErrorText.toLowerCase();
                m_strDBNotFoundErrorCode = (String)this.getProperties().get(SQLParams.DB_NOT_FOUND_ERROR_CODE);
                m_strDuplicateKeyErrorText = (String)this.getProperties().get(SQLParams.DUPLICATE_KEY_ERROR_TEXT);
                if (m_strDuplicateKeyErrorText != null)
                    m_strDuplicateKeyErrorText = m_strDuplicateKeyErrorText.toLowerCase();
                m_strDuplicateKeyErrorCode = (String)this.getProperties().get(SQLParams.DUPLICATE_KEY_ERROR_CODE);
                m_strKeyNotFoundErrorText = (String)this.getProperties().get(SQLParams.KEY_NOT_FOUND_ERROR_TEXT);
                if (m_strKeyNotFoundErrorText != null)
                    m_strKeyNotFoundErrorText = m_strDuplicateKeyErrorText.toLowerCase();
                m_strKeyNotFoundErrorCode = (String)this.getProperties().get(SQLParams.KEY_NOT_FOUND_ERROR_CODE);
                m_strRecordLockedErrorText = (String)this.getProperties().get(SQLParams.RECORD_LOCKED_ERROR_TEXT);
                if (m_strRecordLockedErrorText != null)
                    m_strRecordLockedErrorText = m_strRecordLockedErrorText.toLowerCase();
                m_strRecordLockedErrorCode = (String)this.getProperties().get(SQLParams.RECORD_LOCKED_ERROR_CODE);
                m_strBrokenPipeErrorText = (String)this.getProperties().get(SQLParams.BROKEN_PIPE_ERROR_TEXT);
                if (m_strBrokenPipeErrorText != null)
                    m_strBrokenPipeErrorText = m_strBrokenPipeErrorText.toLowerCase();
                m_strBrokenPipeErrorCode = (String)this.getProperties().get(SQLParams.BROKEN_PIPE_ERROR_CODE);
            }
                // Yeah, I know this is slow, but exceptions are not that common.
            if (this.checkForError(ex, DBConstants.FILE_NOT_FOUND, m_strFileNotFoundErrorText, m_strFileNotFoundErrorCode))
                iError = DBConstants.FILE_NOT_FOUND;
            if (this.checkForError(ex, DBConstants.DB_NOT_FOUND, m_strDBNotFoundErrorText, m_strDBNotFoundErrorCode))
                iError = DBConstants.DB_NOT_FOUND;
            if (this.checkForError(ex, DBConstants.DUPLICATE_KEY, m_strDuplicateKeyErrorText, m_strDuplicateKeyErrorCode))
                iError = DBConstants.DUPLICATE_KEY;
            if (this.checkForError(ex, DBConstants.DUPLICATE_COUNTER, m_strDuplicateKeyErrorText, m_strDuplicateKeyErrorCode))
                iError = DBConstants.DUPLICATE_COUNTER;
            if (this.checkForError(ex, DBConstants.KEY_NOT_FOUND, m_strKeyNotFoundErrorText, m_strKeyNotFoundErrorCode))
                iError = DBConstants.KEY_NOT_FOUND;
            if (this.checkForError(ex, DBConstants.RECORD_LOCKED, m_strRecordLockedErrorText, m_strRecordLockedErrorCode))
                iError = DBConstants.RECORD_LOCKED;
            if (this.checkForError(ex, DBConstants.BROKEN_PIPE, m_strBrokenPipeErrorText, m_strBrokenPipeErrorCode))
                iError = DBConstants.BROKEN_PIPE;
        }
        if (iError == DBConstants.ERROR_RETURN)
        {
            Utility.getLogger().info("Unknown sql exception: " + strMessage);
            eDB = new DatabaseException(strMessage);
        }
        else if (iError == DBConstants.RECORD_LOCKED)
            eDB = new DatabaseException(iError, strMessage);    // On locked, tells user/computer
        else
            eDB = new DatabaseException(iError);    // Standard error
        return eDB;
    }
117362
public int getVersion() throws SQLException {
        try {
            return this.submit(new VersionCallable()).get();
        } catch (InterruptedException e) {
            logger.log(Level.SEVERE, "Failed to get database version", e);
            throw new SQLException(e);
        } catch (ExecutionException e) {
            logger.log(Level.SEVERE, "Failed to get database version", e);
            throw new SQLException(e);
        }
    }
1033398
@Override
    public void executeWithoutTrigger()
        throws EFapsException
    {
        final Context context = Context.getThreadContext();
        ConnectionResource con = null;
        try {

            con = context.getConnectionResource();

            final SQLTable mainTable = getType().getMainTable();

            final long id = executeOneStatement(con, mainTable, getTable2values().get(mainTable), 0);

            setInstance(Instance.get(getInstance().getType(), id));

            getInstance().setExchangeId(this.exchangeId);
            getInstance().setExchangeSystemId(this.exchangeSystemId);

            GeneralInstance.insert(getInstance(), con);

            for (final Entry<SQLTable, List<Value>> entry :  getTable2values().entrySet()) {
                final SQLTable table = entry.getKey();
                if (!table.equals(mainTable) && !table.isReadOnly()) {
                    executeOneStatement(con, table, entry.getValue(), id);
                }
            }
            Queue.registerUpdate(getInstance());
        } finally {

        }
    }
684463
public static void throwSQLException(Exception cause, String theType, String value)
            throws SQLException {
        throw new SQLException("Invalid " + theType + " value: " + value, cause);
    }
223869
@Override
    public ResultSet executeQuery(String sql) throws SQLException
    {
        checkClosed();
        VoltSQL query = VoltSQL.parseSQL(sql);
        if (!query.isOfType(VoltSQL.TYPE_SELECT)) {
            throw SQLError.get(SQLError.ILLEGAL_STATEMENT, sql);
        }
        return this.executeQuery(query);
    }
886180
@Override
    public ResultSet executeQuery() throws SQLException
    {
        checkClosed();
        if (!this.Query.isOfType(VoltSQL.TYPE_EXEC,VoltSQL.TYPE_SELECT)) {
            throw SQLError.get(SQLError.ILLEGAL_STATEMENT, this.Query.toSqlString());
        }
        ResultSet result = this.executeQuery(this.Query.getExecutableQuery(this.parameters));
        this.parameters = this.Query.getParameterArray();
        return result;
    }
1348188
protected <T> T processCheckRowCountError(Transaction t, Exception root, Throwable e, TxCallable<T> process) throws Exception {
        if (e == null) {
            throw root;
        }
        if (e instanceof OptimisticLockException) {
            if ("checkRowCount".equals(e.getStackTrace()[0].getMethodName())) {
                if (process != null)
                    return process.call(t);
            }
        }
        return processCheckRowCountError(t, root, e.getCause(), process);
    }
453556
public int executeUpdate() throws SQLException {
        final boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
        SQLExecuteCallback<Integer> executeCallback = SQLExecuteCallbackFactory.getPreparedUpdateSQLExecuteCallback(getDatabaseType(), isExceptionThrown);
        List<Integer> results = executeCallback(executeCallback);
        if (isAccumulate()) {
            return accumulate(results);
        } else {
            return results.get(0);
        }
    }
760020
@Override
    public boolean execute(String sql) throws SQLException
    {
        checkClosed();
        VoltSQL query = VoltSQL.parseSQL(sql);
        return this.execute(query);
    }