Package io.debezium.connector.oracle
Class OracleConnection
java.lang.Object
io.debezium.jdbc.JdbcConnection
io.debezium.connector.oracle.OracleConnection
- All Implemented Interfaces:
AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interfacestatic classAn exception that indicates the operation failed because the table is not a relational table.Nested classes/interfaces inherited from class io.debezium.jdbc.JdbcConnection
JdbcConnection.BlockingMultiResultSetConsumer, JdbcConnection.BlockingResultSetConsumer, JdbcConnection.CallPreparer, JdbcConnection.ConnectionFactory, JdbcConnection.MultiResultSetConsumer, JdbcConnection.Operations, JdbcConnection.ParameterResultSetConsumer, JdbcConnection.ResultSetConsumer, JdbcConnection.ResultSetExtractor<T extends Object>, JdbcConnection.ResultSetMapper<T extends Object>, JdbcConnection.StatementFactory, JdbcConnection.StatementPreparer -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final PatternPattern to identify abstract data type indices and column names.private final OracleDatabaseVersionThe database version.private static final org.slf4j.Loggerprivate static final PatternPattern to identify a hidden column based on redefining a table with theROWIDoption.private static final intReturned by column metadata in Oracle if no scale is set;private static final Stringprivate static final PatternPattern to identify system generated indices and column names.private static final FieldA field for the raw jdbc url. -
Constructor Summary
ConstructorsConstructorDescriptionOracleConnection(JdbcConfiguration config) OracleConnection(JdbcConfiguration config, boolean showVersion) OracleConnection(JdbcConfiguration config, JdbcConnection.ConnectionFactory connectionFactory) OracleConnection(JdbcConfiguration config, JdbcConnection.ConnectionFactory connectionFactory, boolean showVersion) -
Method Summary
Modifier and TypeMethodDescriptionbuildReselectColumnQuery(TableId tableId, List<String> columns, List<String> keyColumns, org.apache.kafka.connect.data.Struct source) buildSelectWithRowLimits(TableId tableId, int limit, String projection, Optional<String> condition, Optional<String> additionalCondition, String orderBy) static StringconnectionString(JdbcConfiguration config) getAllTableIds(String catalogName) Retrieves allTableIdin a given database catalog, filtering certain ids that should be omitted from the returned set such as special spatial tables and index-organized tables.getColumnsDetails(String databaseCatalog, String schemaNamePattern, String tableName, Tables.TableFilter tableFilter, Tables.ColumnNameFilter columnFilter, DatabaseMetaData metadata, Set<TableId> viewIds) Get the current, most recent system change number.longgetRowCount(String tableName) Returns the number of rows in a given table.getScnAdjustedByTime(Scn scn, Duration adjustment) getScnToTimestamp(Scn scn) Resolve a system change number to a timestamp, return value is in database timezone.Get the current connection's session statistic by name.getTableMetadataDdl(TableId tableId) Generate a given table's DDL metadata.booleanisArchiveLogDestinationValid(String archiveDestinationName) protected booleanDetermine whether the Oracle server has the archive log enabled.booleanbooleanisTableEmpty(String tableName) Returns whether the given table is empty or not.booleanisTableExists(TableId tableId) booleanisTableExists(String tableName) Returns whether the given table exists or not.protected booleanisTableUniqueIndexIncluded(String indexName, String columnName) private <T> Tprotected ColumnEditoroverrideColumn(ColumnEditor column) readTableNames(String databaseCatalog, String schemaNamePattern, String tableNamePattern, String[] tableTypes) readTableUniqueIndices(DatabaseMetaData metadata, TableId id) voidprotected StringresolveCatalogName(String catalogName) private static JdbcConnection.ConnectionFactoryprivate OracleDatabaseVersionvoidsetSessionToPdb(String pdbName) <T> TsingleOptionalValue(String query, JdbcConnection.ResultSetExtractor<T> extractor) Methods inherited from class io.debezium.jdbc.JdbcConnection
call, close, commit, config, connect, connection, connection, connectionString, createTableId, database, escapeEscapeSequence, execute, execute, executeWithoutCommitting, getAttributeDetails, getColumnValue, getQualifiedTableName, isConnected, isNullable, isTableType, isValid, loadKeyStore, parseSqlStatementString, patternBasedFactory, patternBasedFactory, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQueryAndMap, prepareQueryWithBlockingConsumer, prepareUpdate, print, print, query, query, queryAndMap, queryAndMap, querySingleValue, queryWithBlockingConsumer, quotedColumnIdString, quotedTableIdString, readAllCatalogNames, readAllSchemaNames, readAllTableNames, readPrimaryKeyNames, readPrimaryKeyOrUniqueIndexNames, readSchema, readTableColumn, readTablePreparedStatement, readTableStatement, resolveJdbcType, resolveNativeType, rollback, rowToArray, setAutoCommit, setQueryColumnValue, singleResultMapper, supportedTableTypes, tableTypes, username
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
ORACLE_UNSET_SCALE
private static final int ORACLE_UNSET_SCALEReturned by column metadata in Oracle if no scale is set;- See Also:
-
SYS_NC_PATTERN
Pattern to identify system generated indices and column names. -
ADT_INDEX_NAMES_PATTERN
Pattern to identify abstract data type indices and column names. -
MROW_PATTERN
Pattern to identify a hidden column based on redefining a table with theROWIDoption. -
URL
A field for the raw jdbc url. This field has no default value. -
databaseVersion
The database version. -
QUOTED_CHARACTER
- See Also:
-
-
Constructor Details
-
OracleConnection
-
OracleConnection
public OracleConnection(JdbcConfiguration config, JdbcConnection.ConnectionFactory connectionFactory) -
OracleConnection
public OracleConnection(JdbcConfiguration config, JdbcConnection.ConnectionFactory connectionFactory, boolean showVersion) -
OracleConnection
-
-
Method Details
-
setSessionToPdb
-
resetSessionToCdb
public void resetSessionToCdb() -
getOracleVersion
-
resolveOracleDatabaseVersion
-
readTableNames
public Set<TableId> readTableNames(String databaseCatalog, String schemaNamePattern, String tableNamePattern, String[] tableTypes) throws SQLException - Overrides:
readTableNamesin classJdbcConnection- Throws:
SQLException
-
getAllTableIds
Retrieves allTableIdin a given database catalog, filtering certain ids that should be omitted from the returned set such as special spatial tables and index-organized tables.- Parameters:
catalogName- the catalog/database name- Returns:
- set of all table ids for existing table objects
- Throws:
SQLException- if a database exception occurred
-
resolveCatalogName
- Overrides:
resolveCatalogNamein classJdbcConnection
-
readTableUniqueIndices
public List<String> readTableUniqueIndices(DatabaseMetaData metadata, TableId id) throws SQLException - Overrides:
readTableUniqueIndicesin classJdbcConnection- Throws:
SQLException
-
getCurrentTimestamp
- Overrides:
getCurrentTimestampin classJdbcConnection- Throws:
SQLException
-
isTableUniqueIndexIncluded
- Overrides:
isTableUniqueIndexIncludedin classJdbcConnection
-
getCurrentScn
Get the current, most recent system change number.- Returns:
- the current system change number
- Throws:
SQLException- if an exception occurredIllegalStateException- if the query does not return at least one row
-
getTableMetadataDdl
public String getTableMetadataDdl(TableId tableId) throws SQLException, OracleConnection.NonRelationalTableException Generate a given table's DDL metadata.- Parameters:
tableId- table identifier, should never benull- Returns:
- generated DDL
- Throws:
SQLException- if an exception occurred obtaining the DDL metadataOracleConnection.NonRelationalTableException- the table is not a relational table
-
getSessionStatisticByName
Get the current connection's session statistic by name.- Parameters:
name- the name of the statistic to be fetched, must not benull- Returns:
- the session statistic value, never
null - Throws:
SQLException- if an exception occurred obtaining the session statistic value
-
isTableExists
Returns whether the given table exists or not.- Parameters:
tableName- table name, should not benull- Returns:
- true if the table exists, false if it does not
- Throws:
SQLException- if a database exception occurred
-
isTableExists
- Throws:
SQLException
-
isTableEmpty
Returns whether the given table is empty or not.- Parameters:
tableName- table name, should not benull- Returns:
- true if the table has no records, false otherwise
- Throws:
SQLException- if a database exception occurred
-
getRowCount
Returns the number of rows in a given table.- Parameters:
tableName- table name, should not benull- Returns:
- the number of rows
- Throws:
SQLException- if a database exception occurred
-
singleOptionalValue
public <T> T singleOptionalValue(String query, JdbcConnection.ResultSetExtractor<T> extractor) throws SQLException - Throws:
SQLException
-
buildSelectWithRowLimits
public String buildSelectWithRowLimits(TableId tableId, int limit, String projection, Optional<String> condition, Optional<String> additionalCondition, String orderBy) - Overrides:
buildSelectWithRowLimitsin classJdbcConnection
-
connectionString
-
resolveConnectionFactory
-
isArchiveLogMode
protected boolean isArchiveLogMode()Determine whether the Oracle server has the archive log enabled.- Returns:
trueif the server'sLOG_MODEis set toARCHIVELOG, orfalseotherwise
-
getScnToTimestamp
Resolve a system change number to a timestamp, return value is in database timezone. The SCN to TIMESTAMP mapping is only retained for the duration of the flashback query area. This means that eventually the mapping between these values are no longer kept by Oracle and making a call with a SCN value that has aged out will result in an ORA-08181 error. This function explicitly checks for this use case and if a ORA-08181 error is thrown, it is therefore treated as if a value does not exist returning an empty optional value.- Parameters:
scn- the system change number, must not benull- Returns:
- an optional timestamp when the system change number occurred
- Throws:
SQLException- if a database exception occurred
-
getScnAdjustedByTime
- Throws:
SQLException
-
isArchiveLogDestinationValid
- Throws:
SQLException
-
isOnlyOneArchiveLogDestinationValid
- Throws:
SQLException
-
overrideColumn
- Overrides:
overrideColumnin classJdbcConnection
-
getColumnsDetails
protected Map<TableId,List<Column>> getColumnsDetails(String databaseCatalog, String schemaNamePattern, String tableName, Tables.TableFilter tableFilter, Tables.ColumnNameFilter columnFilter, DatabaseMetaData metadata, Set<TableId> viewIds) throws SQLException - Overrides:
getColumnsDetailsin classJdbcConnection- Throws:
SQLException
-
buildReselectColumnQuery
public String buildReselectColumnQuery(TableId tableId, List<String> columns, List<String> keyColumns, org.apache.kafka.connect.data.Struct source) - Overrides:
buildReselectColumnQueryin classJdbcConnection
-
reselectColumns
public Map<String,Object> reselectColumns(String query, TableId tableId, List<String> columns, List<Object> bindValues) throws SQLException - Overrides:
reselectColumnsin classJdbcConnection- Throws:
SQLException
-
optionallyDoInContainer
- Throws:
SQLException
-