public class SqlServerConnection extends JdbcConnection
JdbcConnection extension to be used with Microsoft SQL Server| Modifier and Type | Class and Description |
|---|---|
static class |
SqlServerConnection.CdcEnabledTable |
static interface |
SqlServerConnection.ResultSetExtractor<T> |
JdbcConnection.BlockingMultiResultSetConsumer, JdbcConnection.BlockingResultSetConsumer, JdbcConnection.CallPreparer, JdbcConnection.ConnectionFactory, JdbcConnection.MultiResultSetConsumer, JdbcConnection.Operations, JdbcConnection.ParameterResultSetConsumer, JdbcConnection.ResultSetConsumer, JdbcConnection.ResultSetMapper<T>, JdbcConnection.StatementFactory, JdbcConnection.StatementPreparer| Modifier and Type | Field and Description |
|---|---|
private static int |
CHANGE_TABLE_DATA_COLUMN_OFFSET |
private static JdbcConnection.ConnectionFactory |
FACTORY |
private static String |
GET_ALL_CHANGES_FOR_TABLE |
private static String |
GET_DATABASE_NAME |
private static String |
GET_LIST_OF_CDC_ENABLED_TABLES |
private static String |
GET_LIST_OF_KEY_COLUMNS |
private static String |
GET_LIST_OF_NEW_CDC_ENABLED_TABLES |
private static String |
GET_MAX_LSN |
private static String |
INCREMENT_LSN |
private static String |
LOCK_TABLE |
private static org.slf4j.Logger |
LOGGER |
private BoundedConcurrentHashMap<Lsn,Instant> |
lsnToInstantCache |
private String |
lsnToTimestamp |
private String |
realDatabaseName
actual name of the database, which could differ in casing from the database name given in the connector config.
|
static String |
SERVER_TIMEZONE_PROP_NAME |
private static String |
SQL_SERVER_VERSION |
private static String |
STATEMENTS_PLACEHOLDER |
private ZoneId |
transactionTimezone |
private static String |
URL_PATTERN |
| Constructor and Description |
|---|
SqlServerConnection(Configuration config)
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(ChangeTable[] changeTables,
Lsn intervalFromLsn,
Lsn intervalToLsn,
JdbcConnection.BlockingMultiResultSetConsumer consumer)
Provides all changes recorder by the SQL Server CDC capture process for a set of tables.
|
private static String |
getLsnToTimestamp(boolean supportsAtTimeZone)
Returns the query for obtaining the LSN-to-TIMESTAMP query.
|
Lsn |
getMaxLsn() |
String |
getNameOfChangeTable(String captureName) |
String |
getRealDatabaseName() |
private int |
getSqlServerVersion() |
Table |
getTableSchemaFromChangeTable(ChangeTable changeTable) |
Table |
getTableSchemaFromTable(ChangeTable changeTable) |
Lsn |
incrementLsn(Lsn lsn)
Obtain the next available position in the database log.
|
Set<ChangeTable> |
listOfChangeTables() |
Set<ChangeTable> |
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) |
void |
rollback() |
<T> JdbcConnection.ResultSetMapper<T> |
singleResultMapper(SqlServerConnection.ResultSetExtractor<T> extractor,
String error) |
private boolean |
supportsAtTimeZone()
SELECT ...
|
Instant |
timestampOfLsn(Lsn lsn)
Map a commit LSN to a point in time when the commit happened.
|
call, close, columnsFor, columnsFor, 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, queryWithBlockingConsumer, readAllCatalogNames, readAllSchemaNames, readAllTableNames, readPrimaryKeyNames, readPrimaryKeyOrUniqueIndexNames, readSchema, readTableColumn, readTableNames, readTableUniqueIndices, resolveJdbcType, resolveNativeType, setAutoCommit, tableTypes, usernamepublic static final String SERVER_TIMEZONE_PROP_NAME
private static final String GET_DATABASE_NAME
private static org.slf4j.Logger LOGGER
private static final String STATEMENTS_PLACEHOLDER
private static final String GET_MAX_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 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 BoundedConcurrentHashMap<Lsn,Instant> lsnToInstantCache
public SqlServerConnection(Configuration config)
config - Configuration instance, may not be null.private 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 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(ChangeTable[] 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 processorSQLExceptionInterruptedExceptionpublic 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 <T> JdbcConnection.ResultSetMapper<T> singleResultMapper(SqlServerConnection.ResultSetExtractor<T> extractor, String error) throws SQLException
SQLExceptionpublic Set<ChangeTable> listOfChangeTables() throws SQLException
SQLExceptionpublic Set<ChangeTable> listOfNewChangeTables(Lsn fromLsn, Lsn toLsn) throws SQLException
SQLExceptionpublic Table getTableSchemaFromTable(ChangeTable changeTable) throws SQLException
SQLExceptionpublic Table getTableSchemaFromChangeTable(ChangeTable changeTable) throws SQLException
SQLExceptionpublic void rollback()
throws SQLException
SQLExceptionpublic String getRealDatabaseName()
private ZoneId retrieveTransactionTimezone(boolean supportsAtTimeZone)
private String retrieveRealDatabaseName()
private boolean supportsAtTimeZone()
private int getSqlServerVersion()
Copyright © 2020 JBoss by Red Hat. All rights reserved.