Class Db2Connection

  • All Implemented Interfaces:
    AutoCloseable

    public class Db2Connection
    extends io.debezium.jdbc.JdbcConnection
    Copied from Debezium 1.9.8.Final. JdbcConnection extension to be used with IBM Db2
    Author:
    Horia Chiorean (hchiorea@redhat.com), Jiri Pechanec, Peter Urbanetz
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Db2Connection.CdcEnabledTable  
      • Nested classes/interfaces inherited from class io.debezium.jdbc.JdbcConnection

        io.debezium.jdbc.JdbcConnection.BlockingMultiResultSetConsumer, io.debezium.jdbc.JdbcConnection.BlockingResultSetConsumer, io.debezium.jdbc.JdbcConnection.CallPreparer, io.debezium.jdbc.JdbcConnection.ConnectionFactory, io.debezium.jdbc.JdbcConnection.MultiResultSetConsumer, io.debezium.jdbc.JdbcConnection.Operations, io.debezium.jdbc.JdbcConnection.ParameterResultSetConsumer, io.debezium.jdbc.JdbcConnection.ResultSetConsumer, io.debezium.jdbc.JdbcConnection.ResultSetExtractor<T extends Object>, io.debezium.jdbc.JdbcConnection.ResultSetMapper<T extends Object>, io.debezium.jdbc.JdbcConnection.StatementFactory, io.debezium.jdbc.JdbcConnection.StatementPreparer
    • Constructor Summary

      Constructors 
      Constructor Description
      Db2Connection​(io.debezium.jdbc.JdbcConfiguration config)
      Creates a new connection using the supplied configuration.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String connectionString()
      Returns a JDBC connection string for the current configuration.
      void getChangesForTable​(io.debezium.relational.TableId tableId, io.debezium.connector.db2.Lsn fromLsn, io.debezium.connector.db2.Lsn toLsn, io.debezium.jdbc.JdbcConnection.ResultSetConsumer consumer)
      Provides all changes recorded by the DB2 CDC capture process for a given table.
      void getChangesForTables​(io.debezium.connector.db2.Db2ChangeTable[] changeTables, io.debezium.connector.db2.Lsn intervalFromLsn, io.debezium.connector.db2.Lsn intervalToLsn, io.debezium.jdbc.JdbcConnection.BlockingMultiResultSetConsumer consumer)
      Provides all changes recorder by the DB2 CDC capture process for a set of tables.
      Optional<Timestamp> getCurrentTimestamp()  
      io.debezium.connector.db2.Lsn getMaxLsn()  
      String getNameOfChangeTable​(String captureName)  
      String getRealDatabaseName()  
      io.debezium.relational.Table getTableSchemaFromChangeTable​(io.debezium.connector.db2.Db2ChangeTable changeTable)  
      io.debezium.relational.Table getTableSchemaFromTable​(io.debezium.connector.db2.Db2ChangeTable changeTable)  
      io.debezium.connector.db2.Lsn incrementLsn​(io.debezium.connector.db2.Lsn lsn)
      Obtain the next available position in the database log.
      protected boolean isTableUniqueIndexIncluded​(String indexName, String columnName)  
      Set<io.debezium.connector.db2.Db2ChangeTable> listOfChangeTables()  
      Set<io.debezium.connector.db2.Db2ChangeTable> listOfNewChangeTables​(io.debezium.connector.db2.Lsn fromLsn, io.debezium.connector.db2.Lsn toLsn)  
      void lockTable​(io.debezium.relational.TableId tableId)
      Creates an exclusive lock for a given table.
      String quotedTableIdString​(io.debezium.relational.TableId tableId)  
      List<String> readPrimaryKeyNames​(DatabaseMetaData metadata, io.debezium.relational.TableId id)  
      Set<io.debezium.relational.TableId> readTableNames​(String databaseCatalog, String schemaNamePattern, String tableNamePattern, String[] tableTypes)
      Get the identifiers of the tables.
      List<String> readTableUniqueIndices​(DatabaseMetaData metadata, io.debezium.relational.TableId id)  
      protected String resolveCatalogName​(String catalogName)  
      java.time.Instant timestampOfLsn​(io.debezium.connector.db2.Lsn lsn)
      Map a commit LSN to a point in time when the commit happened.
      • Methods inherited from class io.debezium.jdbc.JdbcConnection

        buildSelectWithRowLimits, call, close, commit, config, connect, connection, connection, connectionString, database, execute, execute, executeWithoutCommitting, getColumnsDetails, getColumnValue, isConnected, isNullable, isTableType, isValid, loadKeyStore, overrideColumn, parseSqlStatementString, patternBasedFactory, patternBasedFactory, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQueryAndMap, prepareQueryWithBlockingConsumer, prepareUpdate, print, print, query, query, queryAndMap, queryAndMap, querySingleValue, queryWithBlockingConsumer, quotedColumnIdString, readAllCatalogNames, readAllSchemaNames, readAllTableNames, readPrimaryKeyOrUniqueIndexNames, readSchema, readTableColumn, readTablePreparedStatement, readTableStatement, resolveJdbcType, resolveNativeType, rollback, rowToArray, setAutoCommit, singleResultMapper, supportedTableTypes, tableTypes, username
    • Constructor Detail

      • Db2Connection

        public Db2Connection​(io.debezium.jdbc.JdbcConfiguration config)
        Creates a new connection using the supplied configuration.
        Parameters:
        config - Configuration instance, may not be null.
    • Method Detail

      • getMaxLsn

        public io.debezium.connector.db2.Lsn getMaxLsn()
                                                throws SQLException
        Returns:
        the current largest log sequence number
        Throws:
        SQLException
      • getChangesForTable

        public void getChangesForTable​(io.debezium.relational.TableId tableId,
                                       io.debezium.connector.db2.Lsn fromLsn,
                                       io.debezium.connector.db2.Lsn toLsn,
                                       io.debezium.jdbc.JdbcConnection.ResultSetConsumer consumer)
                                throws SQLException
        Provides all changes recorded by the DB2 CDC capture process for a given table.
        Parameters:
        tableId - - the requested table changes
        fromLsn - - closed lower bound of interval of changes to be provided
        toLsn - - closed upper bound of interval of changes to be provided
        consumer - - the change processor
        Throws:
        SQLException
      • getChangesForTables

        public void getChangesForTables​(io.debezium.connector.db2.Db2ChangeTable[] changeTables,
                                        io.debezium.connector.db2.Lsn intervalFromLsn,
                                        io.debezium.connector.db2.Lsn intervalToLsn,
                                        io.debezium.jdbc.JdbcConnection.BlockingMultiResultSetConsumer consumer)
                                 throws SQLException,
                                        InterruptedException
        Provides all changes recorder by the DB2 CDC capture process for a set of tables.
        Parameters:
        changeTables - - the requested tables to obtain changes for
        intervalFromLsn - - closed lower bound of interval of changes to be provided
        intervalToLsn - - closed upper bound of interval of changes to be provided
        consumer - - the change processor
        Throws:
        SQLException
        InterruptedException
      • incrementLsn

        public io.debezium.connector.db2.Lsn incrementLsn​(io.debezium.connector.db2.Lsn lsn)
                                                   throws SQLException
        Obtain the next available position in the database log.
        Parameters:
        lsn - - LSN of the current position
        Returns:
        LSN of the next position in the database
        Throws:
        SQLException
      • timestampOfLsn

        public java.time.Instant timestampOfLsn​(io.debezium.connector.db2.Lsn lsn)
                                         throws SQLException
        Map a commit LSN to a point in time when the commit happened.
        Parameters:
        lsn - - LSN of the commit
        Returns:
        time when the commit was recorded into the database log
        Throws:
        SQLException
      • lockTable

        public void lockTable​(io.debezium.relational.TableId tableId)
                       throws SQLException
        Creates an exclusive lock for a given table.
        Parameters:
        tableId - to be locked
        Throws:
        SQLException
      • listOfChangeTables

        public Set<io.debezium.connector.db2.Db2ChangeTable> listOfChangeTables()
                                                                         throws SQLException
        Throws:
        SQLException
      • listOfNewChangeTables

        public Set<io.debezium.connector.db2.Db2ChangeTable> listOfNewChangeTables​(io.debezium.connector.db2.Lsn fromLsn,
                                                                                   io.debezium.connector.db2.Lsn toLsn)
                                                                            throws SQLException
        Throws:
        SQLException
      • getTableSchemaFromTable

        public io.debezium.relational.Table getTableSchemaFromTable​(io.debezium.connector.db2.Db2ChangeTable changeTable)
                                                             throws SQLException
        Throws:
        SQLException
      • getTableSchemaFromChangeTable

        public io.debezium.relational.Table getTableSchemaFromChangeTable​(io.debezium.connector.db2.Db2ChangeTable changeTable)
                                                                   throws SQLException
        Throws:
        SQLException
      • getNameOfChangeTable

        public String getNameOfChangeTable​(String captureName)
      • getRealDatabaseName

        public String getRealDatabaseName()
      • isTableUniqueIndexIncluded

        protected boolean isTableUniqueIndexIncluded​(String indexName,
                                                     String columnName)
        Overrides:
        isTableUniqueIndexIncluded in class io.debezium.jdbc.JdbcConnection
      • connectionString

        public String connectionString()
        Returns a JDBC connection string for the current configuration.
        Returns:
        a String where the variables in urlPattern are replaced with values from the configuration
      • quotedTableIdString

        public String quotedTableIdString​(io.debezium.relational.TableId tableId)
        Overrides:
        quotedTableIdString in class io.debezium.jdbc.JdbcConnection
      • resolveCatalogName

        protected String resolveCatalogName​(String catalogName)
        Overrides:
        resolveCatalogName in class io.debezium.jdbc.JdbcConnection
      • readTableUniqueIndices

        public List<String> readTableUniqueIndices​(DatabaseMetaData metadata,
                                                   io.debezium.relational.TableId id)
                                            throws SQLException
        Overrides:
        readTableUniqueIndices in class io.debezium.jdbc.JdbcConnection
        Throws:
        SQLException
      • readTableNames

        public Set<io.debezium.relational.TableId> readTableNames​(String databaseCatalog,
                                                                  String schemaNamePattern,
                                                                  String tableNamePattern,
                                                                  String[] tableTypes)
                                                           throws SQLException
        Get the identifiers of the tables.
        Overrides:
        readTableNames in class io.debezium.jdbc.JdbcConnection
        Parameters:
        databaseCatalog - the name of the catalog, which is typically the database name; may be an empty string for tables that have no catalog, or null if the catalog name should not be used to narrow the list of table identifiers
        schemaNamePattern - the pattern used to match database schema names, which may be "" to match only those tables with no schema or null if the schema name should not be used to narrow the list of table identifiers
        tableNamePattern - the pattern used to match database table names, which may be null to match all table names
        tableTypes - the set of table types to include in the results, which may be null for all table types
        Returns:
        the set of TableIds; never null but possibly empty
        Throws:
        SQLException - if an error occurs while accessing the database metadata