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.JdbcConnection
JdbcConnection extension to be used with IBM Db2- Author:
- Horia Chiorean (hchiorea@redhat.com), Jiri Pechanec, Peter Urbanetz
-
Nested Class Summary
Nested ClassesNested 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 -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final intprivate static final io.debezium.jdbc.JdbcConnection.ConnectionFactoryprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static org.slf4j.Loggerprivate static final Stringprivate static final Stringprivate final Stringactual name of the database, which could differ in casing from the database name given in the connector config.private static final Stringprivate static final String -
Constructor Summary
ConstructorsConstructorDescriptionDb2Connection(io.debezium.jdbc.JdbcConfiguration config) Creates a new connection using the supplied configuration. -
Method Summary
Modifier and TypeMethodDescriptionprivate StringcdcNameForTable(io.debezium.relational.TableId tableId) private voidclosePreparedStatement(PreparedStatement statement) Returns a JDBC connection string for the current configuration.private PreparedStatementcreatePreparedStatement(String query) io.debezium.relational.TableIdcreateTableId(String databaseName, String schemaName, String tableName) voidgetChangesForTable(io.debezium.relational.TableId tableId, Lsn fromLsn, Lsn toLsn, io.debezium.jdbc.JdbcConnection.ResultSetConsumer consumer) Provides all changes recorded by the DB2 CDC capture process for a given table.voidgetChangesForTables(Db2ChangeTable[] changeTables, Lsn intervalFromLsn, Lsn intervalToLsn, io.debezium.jdbc.JdbcConnection.BlockingMultiResultSetConsumer consumer) Provides all changes recorder by the DB2 CDC capture process for a set of tables.getNameOfChangeTable(String captureName) io.debezium.relational.TablegetTableSchemaFromChangeTable(Db2ChangeTable changeTable) io.debezium.relational.TablegetTableSchemaFromTable(Db2ChangeTable changeTable) incrementLsn(Lsn lsn) Obtain the next available position in the database log.protected booleanisTableUniqueIndexIncluded(String indexName, String columnName) listOfNewChangeTables(Lsn fromLsn, Lsn toLsn) voidlockTable(io.debezium.relational.TableId tableId) Creates an exclusive lock for a given table.io.debezium.jdbc.JdbcConnectionprepareQuery(String preparedQueryString) io.debezium.jdbc.JdbcConnectionprepareQuery(String[] multiQuery, io.debezium.jdbc.JdbcConnection.StatementPreparer[] preparers, io.debezium.jdbc.JdbcConnection.BlockingMultiResultSetConsumer resultConsumer) io.debezium.jdbc.JdbcConnectionprepareQuery(String preparedQueryString, io.debezium.jdbc.JdbcConnection.StatementPreparer preparer, io.debezium.jdbc.JdbcConnection.ResultSetConsumer resultConsumer) io.debezium.jdbc.JdbcConnectionprepareQuery(String preparedQueryString, List<?> parameters, io.debezium.jdbc.JdbcConnection.ParameterResultSetConsumer resultConsumer) <T> TprepareQueryAndMap(String preparedQueryString, io.debezium.jdbc.JdbcConnection.StatementPreparer preparer, io.debezium.jdbc.JdbcConnection.ResultSetMapper<T> mapper) io.debezium.jdbc.JdbcConnectionprepareQueryWithBlockingConsumer(String preparedQueryString, io.debezium.jdbc.JdbcConnection.StatementPreparer preparer, io.debezium.jdbc.JdbcConnection.BlockingResultSetConsumer resultConsumer) io.debezium.jdbc.JdbcConnectionprepareUpdate(String stmt, io.debezium.jdbc.JdbcConnection.StatementPreparer preparer) quotedTableIdString(io.debezium.relational.TableId tableId) private String<T> TsingleOptionalValue(String query, io.debezium.jdbc.JdbcConnection.ResultSetExtractor<T> extractor) timestampOfLsn(Lsn lsn) Map a commit LSN to a point in time when the commit happened.booleanvalidateLogPosition(io.debezium.pipeline.spi.Partition partition, io.debezium.pipeline.spi.OffsetContext offset, io.debezium.config.CommonConnectorConfig config) Methods inherited from class io.debezium.jdbc.JdbcConnection
buildSelectWithRowLimits, call, chunkQueryBuilder, close, commit, config, connect, connection, connection, connectionString, database, escapeEscapeSequence, execute, execute, executeWithoutCommitting, getAttributeDetails, getColumnsDetails, getColumnValue, getQualifiedTableName, isConnected, isNullable, isTableType, isValid, loadKeyStore, overrideColumn, parseSqlStatementString, patternBasedFactory, patternBasedFactory, prepareQuery, print, print, query, query, queryAndMap, queryAndMap, querySingleValue, queryWithBlockingConsumer, quotedColumnIdString, readAllCatalogNames, readAllSchemaNames, readAllTableNames, readPrimaryKeyNames, readPrimaryKeyOrUniqueIndexNames, readSchema, readTableColumn, readTableNames, readTablePreparedStatement, readTableStatement, readTableUniqueIndices, reselectColumns, reselectColumns, resolveCatalogName, resolveJdbcType, resolveNativeType, rollback, rowToArray, setAutoCommit, setQueryColumnValue, singleResultMapper, supportedTableTypes, tableTypes, username
-
Field Details
-
GET_DATABASE_NAME
- See Also:
-
LOGGER
private static org.slf4j.Logger LOGGER -
CDC_SCHEMA
- See Also:
-
STATEMENTS_PLACEHOLDER
- See Also:
-
GET_MAX_LSN
- See Also:
-
LOCK_TABLE
- See Also:
-
LSN_TO_TIMESTAMP
- See Also:
-
GET_ALL_CHANGES_FOR_TABLE
- See Also:
-
GET_LIST_OF_CDC_ENABLED_TABLES
- See Also:
-
GET_LIST_OF_NEW_CDC_ENABLED_TABLES
- See Also:
-
GET_LIST_OF_KEY_COLUMNS
- See Also:
-
CHANGE_TABLE_DATA_COLUMN_OFFSET
private static final int CHANGE_TABLE_DATA_COLUMN_OFFSET- See Also:
-
QUOTED_CHARACTER
- See Also:
-
URL_PATTERN
-
FACTORY
private static final io.debezium.jdbc.JdbcConnection.ConnectionFactory FACTORY -
realDatabaseName
actual name of the database, which could differ in casing from the database name given in the connector config. -
lsnToInstantCache
-
-
Constructor Details
-
Db2Connection
public Db2Connection(io.debezium.jdbc.JdbcConfiguration config) Creates a new connection using the supplied configuration.- Parameters:
config-Configurationinstance, may not be null.
-
-
Method Details
-
getMaxLsn
- Returns:
- the current largest log sequence number
- Throws:
SQLException
-
getChangesForTable
public void getChangesForTable(io.debezium.relational.TableId tableId, Lsn fromLsn, 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 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(Db2ChangeTable[] changeTables, Lsn intervalFromLsn, 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 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
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
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
-
getCurrentTimestamp
- Overrides:
getCurrentTimestampin classio.debezium.jdbc.JdbcConnection- Throws:
SQLException
-
lockTable
Creates an exclusive lock for a given table.- Parameters:
tableId- to be locked- Throws:
SQLException
-
cdcNameForTable
-
listOfChangeTables
- Throws:
SQLException
-
listOfNewChangeTables
- Throws:
SQLException
-
getTableSchemaFromTable
public io.debezium.relational.Table getTableSchemaFromTable(Db2ChangeTable changeTable) throws SQLException - Throws:
SQLException
-
getTableSchemaFromChangeTable
public io.debezium.relational.Table getTableSchemaFromChangeTable(Db2ChangeTable changeTable) throws SQLException - Throws:
SQLException
-
getNameOfChangeTable
-
getRealDatabaseName
-
isTableUniqueIndexIncluded
- Overrides:
isTableUniqueIndexIncludedin classio.debezium.jdbc.JdbcConnection
-
retrieveRealDatabaseName
-
connectionString
Returns a JDBC connection string for the current configuration.- Returns:
- a
Stringwhere the variables inurlPatternare replaced with values from the configuration
-
nullsSortLast
- Overrides:
nullsSortLastin classio.debezium.jdbc.JdbcConnection
-
quotedTableIdString
- Overrides:
quotedTableIdStringin classio.debezium.jdbc.JdbcConnection
-
prepareQuery
public io.debezium.jdbc.JdbcConnection prepareQuery(String[] multiQuery, io.debezium.jdbc.JdbcConnection.StatementPreparer[] preparers, io.debezium.jdbc.JdbcConnection.BlockingMultiResultSetConsumer resultConsumer) throws SQLException, InterruptedException - Overrides:
prepareQueryin classio.debezium.jdbc.JdbcConnection- Throws:
SQLExceptionInterruptedException
-
prepareQueryWithBlockingConsumer
public io.debezium.jdbc.JdbcConnection prepareQueryWithBlockingConsumer(String preparedQueryString, io.debezium.jdbc.JdbcConnection.StatementPreparer preparer, io.debezium.jdbc.JdbcConnection.BlockingResultSetConsumer resultConsumer) throws SQLException, InterruptedException - Overrides:
prepareQueryWithBlockingConsumerin classio.debezium.jdbc.JdbcConnection- Throws:
SQLExceptionInterruptedException
-
prepareQuery
- Overrides:
prepareQueryin classio.debezium.jdbc.JdbcConnection- Throws:
SQLException
-
prepareQuery
public io.debezium.jdbc.JdbcConnection prepareQuery(String preparedQueryString, io.debezium.jdbc.JdbcConnection.StatementPreparer preparer, io.debezium.jdbc.JdbcConnection.ResultSetConsumer resultConsumer) throws SQLException - Overrides:
prepareQueryin classio.debezium.jdbc.JdbcConnection- Throws:
SQLException
-
prepareQueryAndMap
public <T> T prepareQueryAndMap(String preparedQueryString, io.debezium.jdbc.JdbcConnection.StatementPreparer preparer, io.debezium.jdbc.JdbcConnection.ResultSetMapper<T> mapper) throws SQLException - Overrides:
prepareQueryAndMapin classio.debezium.jdbc.JdbcConnection- Throws:
SQLException
-
prepareUpdate
public io.debezium.jdbc.JdbcConnection prepareUpdate(String stmt, io.debezium.jdbc.JdbcConnection.StatementPreparer preparer) throws SQLException - Overrides:
prepareUpdatein classio.debezium.jdbc.JdbcConnection- Throws:
SQLException
-
prepareQuery
public io.debezium.jdbc.JdbcConnection prepareQuery(String preparedQueryString, List<?> parameters, io.debezium.jdbc.JdbcConnection.ParameterResultSetConsumer resultConsumer) throws SQLException - Overrides:
prepareQueryin classio.debezium.jdbc.JdbcConnection- Throws:
SQLException
-
createTableId
public io.debezium.relational.TableId createTableId(String databaseName, String schemaName, String tableName) - Overrides:
createTableIdin classio.debezium.jdbc.JdbcConnection
-
validateLogPosition
public boolean validateLogPosition(io.debezium.pipeline.spi.Partition partition, io.debezium.pipeline.spi.OffsetContext offset, io.debezium.config.CommonConnectorConfig config) -
singleOptionalValue
public <T> T singleOptionalValue(String query, io.debezium.jdbc.JdbcConnection.ResultSetExtractor<T> extractor) throws SQLException - Throws:
SQLException
-
createPreparedStatement
-
closePreparedStatement
-