public class SqlServerConnection extends JdbcConnection
JdbcConnection extension to be used with Microsoft SQL Server| Modifier and Type | Class and Description |
|---|---|
static class |
SqlServerConnection.CdcEnabledTable |
JdbcConnection.BlockingMultiResultSetConsumer, JdbcConnection.BlockingResultSetConsumer, JdbcConnection.CallPreparer, JdbcConnection.ConnectionFactory, JdbcConnection.MultiResultSetConsumer, JdbcConnection.Operations, JdbcConnection.ParameterResultSetConsumer, JdbcConnection.ResultSetConsumer, JdbcConnection.ResultSetExtractor<T>, JdbcConnection.ResultSetMapper<T>, JdbcConnection.StatementFactory, JdbcConnection.StatementPreparer| Constructor and Description |
|---|
SqlServerConnection(Configuration config,
Clock clock,
SourceTimestampMode sourceTimestampMode,
SqlServerValueConverters valueConverters)
Creates a new connection using the supplied configuration.
|
SqlServerConnection(Configuration config,
Clock clock,
SourceTimestampMode sourceTimestampMode,
SqlServerValueConverters valueConverters,
Supplier<ClassLoader> classLoaderSupplier)
Creates a new connection using the supplied configuration.
|
| Modifier and Type | Method and Description |
|---|---|
private String |
cdcNameForTable(TableId tableId) |
void |
getChangesForTable(TableId tableId,
Lsn fromLsn,
Lsn toLsn,
JdbcConnection.ResultSetConsumer consumer)
Provides all changes recorded by the SQL Server CDC capture process for a given table.
|
void |
getChangesForTables(SqlServerChangeTable[] changeTables,
Lsn intervalFromLsn,
Lsn intervalToLsn,
JdbcConnection.BlockingMultiResultSetConsumer consumer)
Provides all changes recorder by the SQL Server CDC capture process for a set of tables.
|
protected Optional<Object> |
getDefaultValue(Column column,
String defaultValue) |
private Lsn |
getFromLsn(SqlServerChangeTable changeTable,
Lsn intervalFromLsn) |
private static String |
getLsnToTimestamp(boolean supportsAtTimeZone)
Returns the query for obtaining the LSN-to-TIMESTAMP query.
|
Lsn |
getMaxLsn() |
MaxLsnResult |
getMaxLsnResult(boolean skipLowActivityLsnsEnabled) |
Lsn |
getMinLsn(String changeTableName) |
String |
getNameOfChangeTable(String captureName) |
String |
getRealDatabaseName() |
private Optional<Integer> |
getSqlServerVersion() |
Table |
getTableSchemaFromChangeTable(SqlServerChangeTable changeTable) |
Table |
getTableSchemaFromTable(SqlServerChangeTable changeTable) |
Lsn |
incrementLsn(Lsn lsn)
Obtain the next available position in the database log.
|
Set<SqlServerChangeTable> |
listOfChangeTables() |
Set<SqlServerChangeTable> |
listOfNewChangeTables(Lsn fromLsn,
Lsn toLsn) |
void |
lockTable(TableId tableId)
Creates an exclusive lock for a given table.
|
private Instant |
normalize(Timestamp timestamp) |
private String |
retrieveRealDatabaseName() |
private ZoneId |
retrieveTransactionTimezone(boolean supportsAtTimeZone) |
private boolean |
supportsAtTimeZone()
SELECT ...
|
Instant |
timestampOfLsn(Lsn lsn)
Map a commit LSN to a point in time when the commit happened.
|
call, close, commit, config, connect, connection, connection, connectionString, database, execute, execute, executeWithoutCommitting, isConnected, isNullable, parseSqlStatementString, patternBasedFactory, patternBasedFactory, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQueryAndMap, prepareQueryWithBlockingConsumer, prepareUpdate, print, print, query, query, queryAndMap, queryAndMap, querySingleValue, queryWithBlockingConsumer, readAllCatalogNames, readAllSchemaNames, readAllTableNames, readPrimaryKeyNames, readPrimaryKeyOrUniqueIndexNames, readSchema, readTableColumn, readTableNames, readTableUniqueIndices, resolveJdbcType, resolveNativeType, rollback, setAutoCommit, singleResultMapper, tableTypes, usernamepublic static final String SERVER_TIMEZONE_PROP_NAME
public static final String INSTANCE_NAME
private static final String GET_DATABASE_NAME
private static final org.slf4j.Logger LOGGER
private static final String STATEMENTS_PLACEHOLDER
private static final String GET_MAX_LSN
private static final String GET_MAX_LSN_SKIP_LOW_ACTIVTY
private static final String GET_MIN_LSN
private static final String LOCK_TABLE
private static final String SQL_SERVER_VERSION
private final String lsnToTimestamp
private static final String INCREMENT_LSN
private static final String GET_ALL_CHANGES_FOR_TABLE
private static final String GET_LIST_OF_CDC_ENABLED_TABLES
private static final String GET_LIST_OF_NEW_CDC_ENABLED_TABLES
private static final String GET_LIST_OF_KEY_COLUMNS
private static final Pattern BRACKET_PATTERN
private static final int CHANGE_TABLE_DATA_COLUMN_OFFSET
private static final String URL_PATTERN
private static final JdbcConnection.ConnectionFactory FACTORY
private final String realDatabaseName
private final ZoneId transactionTimezone
private final SourceTimestampMode sourceTimestampMode
private final Clock clock
private final int queryFetchSize
private final BoundedConcurrentHashMap<Lsn,Instant> lsnToInstantCache
private final SqlServerDefaultValueConverter defaultValueConverter
public SqlServerConnection(Configuration config, Clock clock, SourceTimestampMode sourceTimestampMode, SqlServerValueConverters valueConverters)
config - Configuration instance, may not be null.clock - the clocksourceTimestampMode - strategy for populating source.ts_ms.valueConverters - SqlServerValueConverters instancepublic SqlServerConnection(Configuration config, Clock clock, SourceTimestampMode sourceTimestampMode, SqlServerValueConverters valueConverters, Supplier<ClassLoader> classLoaderSupplier)
config - Configuration instance, may not be null.clock - the clocksourceTimestampMode - strategy for populating source.ts_ms.valueConverters - SqlServerValueConverters instanceclassLoaderSupplier - class loader supplierprivate static String getLsnToTimestamp(boolean supportsAtTimeZone)
SERVER_TIMEZONE_PROP_NAME is not necessary to be given. The
returned TIMESTAMP will be adjusted by the JDBC driver using this VM's TZ (as
required by the JDBC spec), and that same TZ will be applied when converting
the TIMESTAMP value into an Instant.public Lsn getMaxLsn() throws SQLException
SQLExceptionpublic MaxLsnResult getMaxLsnResult(boolean skipLowActivityLsnsEnabled) throws SQLException
SQLExceptionpublic Lsn getMinLsn(String changeTableName) throws SQLException
SQLExceptionpublic void getChangesForTable(TableId tableId, Lsn fromLsn, Lsn toLsn, JdbcConnection.ResultSetConsumer consumer) throws SQLException
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 processorSQLExceptionpublic void getChangesForTables(SqlServerChangeTable[] changeTables, Lsn intervalFromLsn, Lsn intervalToLsn, JdbcConnection.BlockingMultiResultSetConsumer consumer) throws SQLException, InterruptedException
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 processorSQLExceptionInterruptedExceptionprivate Lsn getFromLsn(SqlServerChangeTable changeTable, Lsn intervalFromLsn) throws SQLException
SQLExceptionpublic Lsn incrementLsn(Lsn lsn) throws SQLException
lsn - - LSN of the current positionSQLExceptionpublic Instant timestampOfLsn(Lsn lsn) throws SQLException
lsn - - LSN of the commitSQLExceptionpublic void lockTable(TableId tableId) throws SQLException
tableId - to be lockedSQLExceptionpublic Set<SqlServerChangeTable> listOfChangeTables() throws SQLException
SQLExceptionpublic Set<SqlServerChangeTable> listOfNewChangeTables(Lsn fromLsn, Lsn toLsn) throws SQLException
SQLExceptionpublic Table getTableSchemaFromTable(SqlServerChangeTable changeTable) throws SQLException
SQLExceptionpublic Table getTableSchemaFromChangeTable(SqlServerChangeTable changeTable) throws SQLException
SQLExceptionpublic String getRealDatabaseName()
private ZoneId retrieveTransactionTimezone(boolean supportsAtTimeZone)
private String retrieveRealDatabaseName()
private boolean supportsAtTimeZone()
protected Optional<Object> getDefaultValue(Column column, String defaultValue)
getDefaultValue in class JdbcConnectionCopyright © 2021 JBoss by Red Hat. All rights reserved.