Class BabelfishConnection

java.lang.Object
oracle.jdbc.babelfish.BabelfishGenericProxy
oracle.jdbc.babelfish.BabelfishConnection
All Implemented Interfaces:
OracleTranslatingConnection

public abstract class BabelfishConnection extends BabelfishGenericProxy implements OracleTranslatingConnection
Proxy Superclass for java.sql.Connection interface. It is used by the Oracle JDBC proxy library to proxify java.sql.Connection objects to support the auto translation features.
  • Constructor Details

    • BabelfishConnection

      public BabelfishConnection()
  • Method Details

    • getCreator

      protected abstract Object getCreator()
      Specified by:
      getCreator in class BabelfishGenericProxy
      Returns:
    • getDelegate

      protected abstract Object getDelegate()
      Specified by:
      getDelegate in class BabelfishGenericProxy
      Returns:
    • proxify

      protected abstract Object proxify(Object d, Object creator)
    • translateError

      protected Object translateError(Method m, SQLException ex) throws SQLException
      Interceptor for translation of errors.
      Overrides:
      translateError in class BabelfishGenericProxy
      Returns:
      Throws:
      SQLException
    • post_Methods

      protected Object post_Methods(Method m, Object result)
      Post interceptor. sets up the translator in relevant objects required for handling error translation in those objects.
      Overrides:
      post_Methods in class BabelfishGenericProxy
      Returns:
    • prepareStatement

      public PreparedStatement prepareStatement(String sql) throws SQLException
      Translation enabled implementation of java.sql.Connection#prepareStatement(java.lang.String)
      Parameters:
      sql -
      Returns:
      Throws:
      SQLException
      See Also:
    • prepareStatement

      public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
      Translation enabled implementation of java.sql.Connection#prepareStatement(java.lang.String, int)
      Parameters:
      sql -
      Returns:
      Throws:
      SQLException
      See Also:
    • prepareStatement

      public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
      Translation enabled implementation of java.sql.Connection#prepareStatement(java.lang.String, int[])
      Parameters:
      sql -
      Returns:
      Throws:
      SQLException
      See Also:
    • prepareStatement

      public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
      Translation enabled implementation of java.sql.Connection#prepareStatement(java.lang.String, java.lang.String[])
      Parameters:
      sql -
      Returns:
      Throws:
      SQLException
      See Also:
    • prepareStatement

      public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
      Translation enabled implementation of java.sql.Connection#prepareStatement(java.lang.String, int, int)
      Parameters:
      sql -
      Returns:
      Throws:
      SQLException
      See Also:
    • prepareStatement

      public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
      Translation enabled implementation of java.sql.Connection#prepareStatement(java.lang.String, int, int, int)
      Parameters:
      sql -
      Returns:
      Throws:
      SQLException
      See Also:
    • prepareCall

      public CallableStatement prepareCall(String sql) throws SQLException
      Translation enabled implementation of java.sql.Connection#prepareCall(java.lang.String)
      Parameters:
      sql -
      Returns:
      Throws:
      SQLException
      See Also:
    • prepareCall

      public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
      Translation enabled implementation of java.sql.Connection#prepareCall(java.lang.String, int, int)
      Parameters:
      sql -
      Returns:
      Throws:
      SQLException
      See Also:
    • prepareCall

      public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
      Translation enabled implementation of java.sql.Connection#prepareCall(java.lang.String, int, int, int)
      Parameters:
      sql -
      Returns:
      Throws:
      SQLException
      See Also:
    • nativeSQL

      public String nativeSQL(String sql) throws SQLException
      Converts the given foreign dialect SQL statement into the system's native SQL grammar. A driver may convert the JDBC SQL grammar into its system's native SQL grammar prior to sending it. This method returns the native form of the statement that the driver would have sent.
      Parameters:
      sql - a foreign dialect SQL statement that may contain one or more '?' parameter placeholders
      Returns:
      the native form of this statement
      Throws:
      SQLException - if a database access error occurs or this method is called on a closed connection
    • close

      public void close() throws SQLException
      Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released.

      Calling the method close on a Connection object that is already closed is a no-op.

      It is strongly recommended that an application explicitly commits or rolls back an active transaction prior to calling the close method. If the close method is called and there is an active transaction, the results are implementation-defined.

      Throws:
      SQLException - SQLException if a database access error occurs
    • createStatement

      public Statement createStatement() throws SQLException
      Creates a Statement with translation features enabled
      Throws:
      SQLException
      See Also:
    • createStatement

      public Statement createStatement(boolean translation) throws SQLException
      Similar to createStatement() but with an additional translation flag. If the translation flag is true then the returning Statement will have translation enabled. If the flag is false then the returning Statement will be a normal Statement with no translation features.
      Specified by:
      createStatement in interface OracleTranslatingConnection
      Parameters:
      translation - boolean flag to enable or disable translation
      Throws:
      SQLException
    • createStatement

      public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
      Returns a Statement with translation features enabled
      Returns:
      Throws:
      SQLException
      See Also:
    • createStatement

      public Statement createStatement(int resultSetType, int resultSetConcurrency, boolean translation) throws SQLException
      Similar to createStatement(int resultSetType, int resultSetConcurrency) but with an additional translation flag. If the translation flag is true then the returning Statement will have translation enabled. If the flag is false then the returning Statement will be a normal Statement with no translation features.
      Specified by:
      createStatement in interface OracleTranslatingConnection
      Parameters:
      translation - boolean flag to enable or disable translation
      Throws:
      SQLException
    • createStatement

      public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
      Returns a Statement with translation features enabled
      Returns:
      Throws:
      SQLException
      See Also:
    • createStatement

      public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability, boolean translation) throws SQLException
      Similar to createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) but with an additional translation flag. If the translation flag is true then the returning Statement will have translation enabled. If the flag is false then the returning Statement will be a normal Statement with no translation features.
      Specified by:
      createStatement in interface OracleTranslatingConnection
      Parameters:
      translation - boolean flag to enable or disable translation
      Throws:
      SQLException
    • prepareStatement

      public PreparedStatement prepareStatement(String sql, boolean translation) throws SQLException
      Similar to prepareStatement(String sql) but with an additional translation flag. If the translation flag is true then the returning PreparedStatement will have translation enabled. If the flag is false then the returning PreparedStatement will be a normal PreparedStatement with no translation features.
      Specified by:
      prepareStatement in interface OracleTranslatingConnection
      Parameters:
      translation - boolean flag to enable or disable translation
      Throws:
      SQLException
    • prepareStatement

      public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys, boolean translation) throws SQLException
      Similar to prepareStatement(String sql, int autoGeneratedKeys) but with an additional translation flag. If the translation flag is true then the returning PreparedStatement will have translation enabled. If the flag is false then the returning PreparedStatement will be a normal PreparedStatement with no translation features.
      Specified by:
      prepareStatement in interface OracleTranslatingConnection
      Parameters:
      translation - boolean flag to enable or disable translation
      Throws:
      SQLException
    • prepareStatement

      public PreparedStatement prepareStatement(String sql, int[] columnIndexes, boolean translation) throws SQLException
      Similar to prepareStatement(String sql, int[] columnIndexes) but with an additional translation flag. If the translation flag is true then the returning PreparedStatement will have translation enabled. If the flag is false then the returning PreparedStatement will be a normal PreparedStatement with no translation features.
      Specified by:
      prepareStatement in interface OracleTranslatingConnection
      Parameters:
      translation - boolean flag to enable or disable translation
      Throws:
      SQLException
    • prepareStatement

      public PreparedStatement prepareStatement(String sql, String[] columnNames, boolean translation) throws SQLException
      Similar to prepareStatement(String sql, String[] columnNames) but with an additional translation flag. If the translation flag is true then the returning PreparedStatement will have translation enabled. If the flag is false then the returning PreparedStatement will be a normal PreparedStatement with no translation features.
      Specified by:
      prepareStatement in interface OracleTranslatingConnection
      Parameters:
      translation - boolean flag to enable or disable translation
      Throws:
      SQLException
    • prepareStatement

      public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, boolean translation) throws SQLException
      Similar to prepareStatement(String sql, int resultSetType, int resultSetConcurrency) but with an additional translation flag. If the translation flag is true then the returning PreparedStatement will have translation enabled. If the flag is false then the returning PreparedStatement will be a normal PreparedStatement with no translation features.
      Specified by:
      prepareStatement in interface OracleTranslatingConnection
      Parameters:
      translation - boolean flag to enable or disable translation
      Throws:
      SQLException
    • prepareStatement

      public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability, boolean translation) throws SQLException
      Similar to prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) but with an additional translation flag. If the translation flag is true then the returning PreparedStatement will have translation enabled. If the flag is false then the returning PreparedStatement will be a normal PreparedStatement with no translation features.
      Specified by:
      prepareStatement in interface OracleTranslatingConnection
      Parameters:
      translation - boolean flag to enable or disable translation
      Throws:
      SQLException
    • prepareCall

      public CallableStatement prepareCall(String sql, boolean translation) throws SQLException
      Similar to prepareCall(String sql) but with an additional translation flag. If the translation flag is true then the returning CallableStatement will have translation enabled. If the flag is false then the returning CallableStatement will be a normal CallableStatement with no translation features.
      Specified by:
      prepareCall in interface OracleTranslatingConnection
      Parameters:
      translation - boolean flag to enable or disable translation
      Throws:
      SQLException
    • prepareCall

      public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, boolean translation) throws SQLException
      Similar to prepareCall(String sql, int resultSetType, int resultSetConcurrency) but with an additional translation flag. If the translation flag is true then the returning CallableStatement will have translation enabled. If the flag is false then the returning CallableStatement will be a normal CallableStatement with no translation features.
      Specified by:
      prepareCall in interface OracleTranslatingConnection
      Parameters:
      translation - boolean flag to enable or disable translation
      Throws:
      SQLException
    • prepareCall

      public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability, boolean translation) throws SQLException
      Similar to prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) but with an additional translation flag. If the translation flag is true then the returning CallableStatement will have translation enabled. If the flag is false then the returning CallableStatement will be a normal CallableStatement with no translation features.
      Specified by:
      prepareCall in interface OracleTranslatingConnection
      Parameters:
      translation - boolean flag to enable or disable translation
      Throws:
      SQLException
    • getSqlTranslationVersions

      public Map<OracleTranslatingConnection.SqlTranslationVersion,String> getSqlTranslationVersions(String sql, boolean suppressExceptions) throws SQLException
      Returns a map of all the translation versions of the query during SQL Translation. See the documentation of OracleTranslatingConnection.SqlTranslationVersion enum for more details about returning versions.
      Specified by:
      getSqlTranslationVersions in interface OracleTranslatingConnection
      Parameters:
      sql - vendor specific sql to be translated
      suppressExceptions - suppresses any exception raised during query translation and returns whatever is available. Useful to get JDBC_MARKER_CONVERTED version when the translation is throwing error.
      Returns:
      Map with all the translation versions of a query. In case of an Exception and suppressExceptions is true then the TRANSLATED version is null.
      Throws:
      SQLException - If there is a problem in query translation provided suppressExceptions is false.
      See Also: