Interface AQServerConnection


  • public interface AQServerConnection
    This interface represents a database server connection.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void changeDatabase​(java.lang.String name)
      Change database in the current connection.
      void changeSchema​(java.lang.String name)
      Change schema in the current connection.
      void commit()
      Commits a transaction.
      void connect()
      Establish SQL connection to the server.
      void connect​(java.lang.Object password)
      Establish SQL connection to the server with the provided password.
      void connect​(java.lang.Object username, java.lang.Object password)
      Establish SQL connection to the server with the provided user credentials.
      void disconnect()
      Disconnect a server connection.
      boolean execute​(java.lang.String sql)
      Execute a query.
      AQResultSet executeQuery​(java.lang.String sql)
      Execute a query to get a result set.
      AQScriptResult executeScript​(java.lang.String script)
      Executes a script, which may contain multiple statements, and may produce multiple result sets.
      AQDataSet executeSnapshot​(java.lang.String sql)
      Execute query and extract data into AQDataSet.
      int executeUpdate​(java.lang.String sql)
      Execute an update query.
      java.lang.String getCurrentDatabase()
      Get the current database the connection is connected to.
      java.sql.Connection getJdbcConnection()
      Returns underlying JDBC connection.
      AQMetadata getMetadata()
      Get metadata object which allows for introspection of the database structure.
      java.lang.String getName()
      Get connection name (as seen in the schema tree).
      AQScriptOptions getScriptOptions()
      Returns an instance of AQScriptOption object associated with the given connection.
      java.lang.String getSessionID()
      To get the connection session id.
      java.lang.String getVersionString()
      Get database/server version.
      boolean isCaseSensitive()
      Returns true if names in this connections are case sensitive.
      boolean isConnected()
      Get the connection status of the connection session.
      AQScriptOptions newScriptOptions()
      Creates a copy of AQScriptOption object associated with the given connection.
      AQScriptParser newScriptParser()
      Creates a new script parser object.
      AQSqlFormatter newSqlFormat()
      Creates new SQL formatter object.
      void rollback()
      Rolls back a transaction.
      void setAutoCommit​(boolean enable)
      Sets auto-commit mode.
      java.lang.String sqlEncode​(java.lang.String string)
      Escapes single quote characters in a string to make it safe for inclusion into a SQL query.
    • Method Detail

      • getName

        java.lang.String getName()
        Get connection name (as seen in the schema tree).
        Returns:
        The name of the connection.
      • getSessionID

        java.lang.String getSessionID()
        To get the connection session id.
        Returns:
        The session id, as a string, if available; empty string if it is not available.
      • getMetadata

        AQMetadata getMetadata()
        Get metadata object which allows for introspection of the database structure.
        Returns:
        An AQMetaData object;
      • execute

        boolean execute​(java.lang.String sql)
                 throws java.lang.Exception
        Execute a query.
        Parameters:
        sql - The SQL statement.
        Returns:
        true : If the first result is a ResultSet object;
        false: If it is an update count or there are no results.
        Throws:
        java.lang.Exception - on error. eg. if SQL statement
      • executeUpdate

        int executeUpdate​(java.lang.String sql)
                   throws java.lang.Exception
        Execute an update query.
        Parameters:
        sql - The SQL statement.
        Returns:
        An integer value of either
        1. the row count for SQL Data Manipulation Language (DML) statements
        2. 0 for SQL statements that return nothing.
        Throws:
        java.lang.Exception - If SQL statement is not a data manipulation statement.
      • executeQuery

        AQResultSet executeQuery​(java.lang.String sql)
                          throws java.lang.Exception
        Execute a query to get a result set.
        Parameters:
        sql - The SQL statement.
        Returns:
        An AQResultSet object.
        Throws:
        java.lang.Exception - If SQL statement is a data manipulation statement.
      • executeSnapshot

        AQDataSet executeSnapshot​(java.lang.String sql)
                           throws java.lang.Exception
        Execute query and extract data into AQDataSet. Since the data will be cached in memory, the size of data set may be limited by available memory.
        Parameters:
        sql - The SQL statement.
        Returns:
        An AQDataSet object.
        Throws:
        java.lang.Exception - on error.
      • connect

        void connect()
              throws java.lang.Exception
        Establish SQL connection to the server.
        Throws:
        java.lang.Exception - on error.
      • connect

        void connect​(java.lang.Object password)
              throws java.lang.Exception
        Establish SQL connection to the server with the provided password.
        Parameters:
        password - A String password or a AQOpaqueObject with the password.
        Throws:
        java.lang.Exception - on error.
      • connect

        void connect​(java.lang.Object username,
                     java.lang.Object password)
              throws java.lang.Exception
        Establish SQL connection to the server with the provided user credentials.
        Parameters:
        username - A String or a AQOpaqueObject with the user name.
        password - A String password or a AQOpaqueObject with the password.
        Throws:
        java.lang.Exception - on error.
      • isConnected

        boolean isConnected()
        Get the connection status of the connection session.
        Returns:
        true - If server is valid or has not been closed
        false - If connection is not valid or has been closed.
      • disconnect

        void disconnect()
        Disconnect a server connection.
      • getVersionString

        java.lang.String getVersionString()
        Get database/server version.
        Returns:
        The database version string.
      • isCaseSensitive

        boolean isCaseSensitive()
        Returns true if names in this connections are case sensitive.
        Returns:
        TRUE if it is case sensitive
      • changeDatabase

        void changeDatabase​(java.lang.String name)
                     throws java.lang.Exception
        Change database in the current connection. This method only supports databases that support multiple database connections per connection.
        Parameters:
        name - The name of the database.
        Throws:
        java.lang.Exception - On error
      • changeSchema

        void changeSchema​(java.lang.String name)
                   throws java.lang.Exception
        Change schema in the current connection. This method only supports databases that support schemas.
        Parameters:
        name - The name of the schema.
        Throws:
        java.lang.Exception - On error
      • executeScript

        AQScriptResult executeScript​(java.lang.String script)
                              throws java.lang.Exception
        Executes a script, which may contain multiple statements, and may produce multiple result sets.
        Parameters:
        script - The script to be executed.
        Returns:
        the script result
        Throws:
        java.lang.Exception - On error
      • sqlEncode

        java.lang.String sqlEncode​(java.lang.String string)
        Escapes single quote characters in a string to make it safe for inclusion into a SQL query. Depending on the database, the backslash characters will also be escaped.
        Parameters:
        string - The string to be encoded.
        Returns:
        The encoded string.
      • getScriptOptions

        AQScriptOptions getScriptOptions()
        Returns an instance of AQScriptOption object associated with the given connection. This allows the user to set user optional quote identifiers, line separators, statement separators, etc.
        Returns:
        An AQScriptOptions object in use in this specific connection.
      • newScriptOptions

        AQScriptOptions newScriptOptions()
        Creates a copy of AQScriptOption object associated with the given connection. Any changes made to this instance do not affect options associated with the given connection.
        Returns:
        the script options
      • newSqlFormat

        AQSqlFormatter newSqlFormat()
        Creates new SQL formatter object.
        Returns:
        the SQL formmatter
      • newScriptParser

        AQScriptParser newScriptParser()
        Creates a new script parser object.
        Returns:
        AQScriptParser
      • getCurrentDatabase

        java.lang.String getCurrentDatabase()
        Get the current database the connection is connected to.
        Returns:
        The database name.
      • getJdbcConnection

        java.sql.Connection getJdbcConnection()
        Returns underlying JDBC connection.
        Returns:
        an instance of Connection
      • setAutoCommit

        void setAutoCommit​(boolean enable)
                    throws java.lang.Exception
        Sets auto-commit mode. This method is equivalent of Connection.setAutoCommit(boolean).
        Parameters:
        enable - to enable/disable
        Throws:
        java.lang.Exception - On error
      • rollback

        void rollback()
               throws java.lang.Exception
        Rolls back a transaction. This method is equivalent of Connection.rollback().
        Throws:
        java.lang.Exception - On error
      • commit

        void commit()
             throws java.lang.Exception
        Commits a transaction. This method is equivalent of Connection.commit().
        Throws:
        java.lang.Exception - On error