Package io.debezium.connector.db2
Class Db2Connection
- java.lang.Object
-
- io.debezium.jdbc.JdbcConnection
-
- io.debezium.connector.db2.Db2Connection
-
- All Implemented Interfaces:
AutoCloseable
public class Db2Connection extends io.debezium.jdbc.JdbcConnectionCopied from Debezium 1.9.8.Final.JdbcConnectionextension 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 classDb2Connection.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 StringconnectionString()Returns a JDBC connection string for the current configuration.voidgetChangesForTable(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.voidgetChangesForTables(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.LsngetMaxLsn()StringgetNameOfChangeTable(String captureName)StringgetRealDatabaseName()io.debezium.relational.TablegetTableSchemaFromChangeTable(io.debezium.connector.db2.Db2ChangeTable changeTable)io.debezium.relational.TablegetTableSchemaFromTable(io.debezium.connector.db2.Db2ChangeTable changeTable)io.debezium.connector.db2.LsnincrementLsn(io.debezium.connector.db2.Lsn lsn)Obtain the next available position in the database log.protected booleanisTableUniqueIndexIncluded(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)voidlockTable(io.debezium.relational.TableId tableId)Creates an exclusive lock for a given table.StringquotedTableIdString(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 StringresolveCatalogName(String catalogName)java.time.InstanttimestampOfLsn(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
-
-
-
-
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 SQLExceptionProvides all changes recorded by the DB2 CDC capture process for a given table.- Parameters:
tableId- - the requested table changesfromLsn- - closed lower bound of interval of changes to be providedtoLsn- - closed upper bound of interval of changes to be providedconsumer- - 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, InterruptedExceptionProvides all changes recorder by the DB2 CDC capture process for a set of tables.- Parameters:
changeTables- - the requested tables to obtain changes forintervalFromLsn- - closed lower bound of interval of changes to be providedintervalToLsn- - closed upper bound of interval of changes to be providedconsumer- - the change processor- Throws:
SQLExceptionInterruptedException
-
incrementLsn
public io.debezium.connector.db2.Lsn incrementLsn(io.debezium.connector.db2.Lsn lsn) throws SQLExceptionObtain 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 SQLExceptionMap 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
-
getCurrentTimestamp
public Optional<Timestamp> getCurrentTimestamp() throws SQLException
- Overrides:
getCurrentTimestampin classio.debezium.jdbc.JdbcConnection- Throws:
SQLException
-
lockTable
public void lockTable(io.debezium.relational.TableId tableId) throws SQLExceptionCreates 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
-
getRealDatabaseName
public String getRealDatabaseName()
-
isTableUniqueIndexIncluded
protected boolean isTableUniqueIndexIncluded(String indexName, String columnName)
- Overrides:
isTableUniqueIndexIncludedin classio.debezium.jdbc.JdbcConnection
-
connectionString
public String connectionString()
Returns a JDBC connection string for the current configuration.- Returns:
- a
Stringwhere the variables inurlPatternare replaced with values from the configuration
-
quotedTableIdString
public String quotedTableIdString(io.debezium.relational.TableId tableId)
- Overrides:
quotedTableIdStringin classio.debezium.jdbc.JdbcConnection
-
resolveCatalogName
protected String resolveCatalogName(String catalogName)
- Overrides:
resolveCatalogNamein classio.debezium.jdbc.JdbcConnection
-
readPrimaryKeyNames
public List<String> readPrimaryKeyNames(DatabaseMetaData metadata, io.debezium.relational.TableId id) throws SQLException
- Overrides:
readPrimaryKeyNamesin classio.debezium.jdbc.JdbcConnection- Throws:
SQLException
-
readTableUniqueIndices
public List<String> readTableUniqueIndices(DatabaseMetaData metadata, io.debezium.relational.TableId id) throws SQLException
- Overrides:
readTableUniqueIndicesin classio.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:
readTableNamesin classio.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, ornullif the catalog name should not be used to narrow the list of table identifiersschemaNamePattern- the pattern used to match database schema names, which may be "" to match only those tables with no schema ornullif the schema name should not be used to narrow the list of table identifierstableNamePattern- the pattern used to match database table names, which may be null to match all table namestableTypes- 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
-
-