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.JdbcConnectionJdbcConnectionextension 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.CdcEnabledTableprivate static interfaceDb2Connection.ResultSetExtractor<T>-
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.ResultSetMapper<T extends Object>, io.debezium.jdbc.JdbcConnection.StatementFactory, io.debezium.jdbc.JdbcConnection.StatementPreparer
-
-
Field Summary
Fields Modifier and Type Field Description private static StringCDC_SCHEMAprivate static intCHANGE_TABLE_DATA_COLUMN_OFFSETprivate static io.debezium.jdbc.JdbcConnection.ConnectionFactoryFACTORYprivate static StringGET_ALL_CHANGES_FOR_TABLEprivate static StringGET_DATABASE_NAMEprivate static StringGET_LIST_OF_CDC_ENABLED_TABLESprivate static StringGET_LIST_OF_KEY_COLUMNSprivate static StringGET_LIST_OF_NEW_CDC_ENABLED_TABLESprivate static StringGET_MAX_LSNprivate static StringLOCK_TABLEprivate static org.slf4j.LoggerLOGGERprivate static StringLSN_TO_TIMESTAMPprivate io.debezium.util.BoundedConcurrentHashMap<Lsn,Instant>lsnToInstantCacheprivate StringrealDatabaseNameactual name of the database, which could differ in casing from the database name given in the connector config.private static StringSTATEMENTS_PLACEHOLDERprivate static StringURL_PATTERN
-
Constructor Summary
Constructors Constructor Description Db2Connection(io.debezium.config.Configuration config)Creates a new connection using the supplied configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private StringcdcNameForTable(io.debezium.relational.TableId tableId)StringconnectionString()Returns a JDBC connection string for the current configuration.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.LsngetMaxLsn()StringgetNameOfChangeTable(String captureName)StringgetRealDatabaseName()io.debezium.relational.TablegetTableSchemaFromChangeTable(Db2ChangeTable changeTable)io.debezium.relational.TablegetTableSchemaFromTable(Db2ChangeTable changeTable)LsnincrementLsn(Lsn lsn)Obtain the next available position in the database log.protected booleanisTableUniqueIndexIncluded(String indexName, String columnName)Set<Db2ChangeTable>listOfChangeTables()Set<Db2ChangeTable>listOfNewChangeTables(Lsn fromLsn, Lsn toLsn)voidlockTable(io.debezium.relational.TableId tableId)Creates an exclusive lock for a given table.StringquotedTableIdString(io.debezium.relational.TableId tableId)private StringretrieveRealDatabaseName()InstanttimestampOfLsn(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, getColumnValue, getDefaultValue, isConnected, isNullable, parseSqlStatementString, patternBasedFactory, patternBasedFactory, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQueryAndMap, prepareQueryWithBlockingConsumer, prepareUpdate, print, print, query, query, queryAndMap, queryAndMap, querySingleValue, queryWithBlockingConsumer, readAllCatalogNames, readAllSchemaNames, readAllTableNames, readPrimaryKeyNames, readPrimaryKeyOrUniqueIndexNames, readSchema, readTableColumn, readTableNames, readTablePreparedStatement, readTableStatement, readTableUniqueIndices, resolveJdbcType, resolveNativeType, rollback, rowToArray, setAutoCommit, singleResultMapper, tableTypes, username
-
-
-
-
Field Detail
-
GET_DATABASE_NAME
private static final String GET_DATABASE_NAME
- See Also:
- Constant Field Values
-
LOGGER
private static org.slf4j.Logger LOGGER
-
CDC_SCHEMA
private static final String CDC_SCHEMA
- See Also:
- Constant Field Values
-
STATEMENTS_PLACEHOLDER
private static final String STATEMENTS_PLACEHOLDER
- See Also:
- Constant Field Values
-
GET_MAX_LSN
private static final String GET_MAX_LSN
- See Also:
- Constant Field Values
-
LOCK_TABLE
private static final String LOCK_TABLE
- See Also:
- Constant Field Values
-
LSN_TO_TIMESTAMP
private static final String LSN_TO_TIMESTAMP
- See Also:
- Constant Field Values
-
GET_ALL_CHANGES_FOR_TABLE
private static final String GET_ALL_CHANGES_FOR_TABLE
- See Also:
- Constant Field Values
-
GET_LIST_OF_CDC_ENABLED_TABLES
private static final String GET_LIST_OF_CDC_ENABLED_TABLES
- See Also:
- Constant Field Values
-
GET_LIST_OF_NEW_CDC_ENABLED_TABLES
private static final String GET_LIST_OF_NEW_CDC_ENABLED_TABLES
- See Also:
- Constant Field Values
-
GET_LIST_OF_KEY_COLUMNS
private static final String GET_LIST_OF_KEY_COLUMNS
- See Also:
- Constant Field Values
-
CHANGE_TABLE_DATA_COLUMN_OFFSET
private static final int CHANGE_TABLE_DATA_COLUMN_OFFSET
- See Also:
- Constant Field Values
-
URL_PATTERN
private static final String URL_PATTERN
-
FACTORY
private static final io.debezium.jdbc.JdbcConnection.ConnectionFactory FACTORY
-
realDatabaseName
private final String realDatabaseName
actual name of the database, which could differ in casing from the database name given in the connector config.
-
-
Method Detail
-
getMaxLsn
public Lsn getMaxLsn() throws SQLException
- 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 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(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
public Lsn incrementLsn(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 Instant timestampOfLsn(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 SQLExceptionCreates an exclusive lock for a given table.- Parameters:
tableId- to be locked- Throws:
SQLException
-
cdcNameForTable
private String cdcNameForTable(io.debezium.relational.TableId tableId)
-
listOfChangeTables
public Set<Db2ChangeTable> listOfChangeTables() throws SQLException
- Throws:
SQLException
-
listOfNewChangeTables
public Set<Db2ChangeTable> listOfNewChangeTables(Lsn fromLsn, Lsn toLsn) throws SQLException
- 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
-
getRealDatabaseName
public String getRealDatabaseName()
-
isTableUniqueIndexIncluded
protected boolean isTableUniqueIndexIncluded(String indexName, String columnName)
- Overrides:
isTableUniqueIndexIncludedin classio.debezium.jdbc.JdbcConnection
-
retrieveRealDatabaseName
private String retrieveRealDatabaseName()
-
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
-
-