Package io.debezium.jdbc
Class JdbcConnection
java.lang.Object
io.debezium.jdbc.JdbcConnection
- All Implemented Interfaces:
AutoCloseable
A utility that simplifies using a JDBC connection and executing transactions composed of multiple statements.
- Author:
- Randall Hauch
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
Establishes JDBC connections.private class
static interface
static interface
Defines multiple JDBC operations.static interface
static interface
static interface
Extracts a data of resultset..static interface
static interface
A function to create a statement from a connection.static interface
-
Field Summary
Modifier and TypeFieldDescriptionprivate final String
private final JdbcConfiguration
private Connection
private static final int
private final JdbcConnection.ConnectionFactory
private final JdbcConnection.Operations
private static final org.slf4j.Logger
private final String
private static final int
private static final char
private final Map<String,
PreparedStatement> private static final int
-
Constructor Summary
ModifierConstructorDescriptionprotected
JdbcConnection
(JdbcConfiguration config, JdbcConnection.ConnectionFactory connectionFactory, JdbcConnection.Operations initialOperations, Supplier<ClassLoader> classLoaderSupplier, String openingQuotingChar, String closingQuotingChar) Create a new instance with the given configuration and connection factory, and specify the operations that should be run against each newly-established connection.JdbcConnection
(JdbcConfiguration config, JdbcConnection.ConnectionFactory connectionFactory, String openingQuoteCharacter, String closingQuoteCharacter) Create a new instance with the given configuration and connection factory.JdbcConnection
(JdbcConfiguration config, JdbcConnection.ConnectionFactory connectionFactory, Supplier<ClassLoader> classLoaderSupplier, String openingQuoteCharacter, String closingQuoteCharacter) Create a new instance with the given configuration and connection factory. -
Method Summary
Modifier and TypeMethodDescriptionbuildSelectWithRowLimits
(TableId tableId, int limit, String projection, Optional<String> condition, String orderBy) call
(String sql, JdbcConnection.CallPreparer callPreparer, JdbcConnection.ResultSetConsumer resultSetConsumer) Execute a stored procedure.private void
cleanupPreparedStatement
(PreparedStatement statement) void
close()
Close the connection and release any resources.private static Field[]
combineVariables
(Field[] overriddenVariables, Field... defaultVariables) commit()
config()
Obtain the configuration for this connection.connect()
Ensure a connection to the database is established.connection
(boolean executeOnConnect) connectionString
(String urlPattern) Returns a JDBC connection string using the current configuration and url.private PreparedStatement
createPreparedStatement
(String preparedQueryString) database()
Returns the database name for this connectionprivate String
delimiter
(int columnCount, int[] columnSizes) private void
doClose()
execute
(JdbcConnection.Operations operations) Execute a series of operations as a single transaction.Execute a series of SQL statements as a single transaction.executeWithoutCommitting
(String... statements) Executes a series of statements without explicitly committing the connection.private static String
findAndReplace
(String url, String name, Properties props, String defaultValue) private static String
findAndReplace
(String url, Properties props, Field... variables) private int[]
findMaxLength
(ResultSet resultSet) getColumnsDetails
(String databaseCatalog, String schemaNamePattern, String tableName, Tables.TableFilter tableFilter, Tables.ColumnNameFilter columnFilter, DatabaseMetaData metadata, Set<TableId> viewIds) <T extends DatabaseSchema<TableId>>
ObjectgetColumnValue
(ResultSet rs, int columnIndex, Column column, Table table, T schema) Reads a value from JDBC result set and execute per-connector conversion if neededboolean
protected static boolean
isNullable
(int jdbcNullable) protected boolean
isTableUniqueIndexIncluded
(String indexName, String columnName) Allows the connector implementation to determine if a table's unique index should be include when resolving a table's unique indices.boolean
isValid()
loadKeyStore
(String filePath, char[] passwordArray) Read JKS type keystore/truststore file according related password.protected ColumnEditor
overrideColumn
(ColumnEditor column) Allow implementations an opportunity to adjust the current state of theColumnEditor
that has been seeded with data from the column metadata from the JDBC driver.parseSqlStatementString
(String statements) patternBasedFactory
(String urlPattern, Field... variables) Create aJdbcConnection.ConnectionFactory
that replaces variables in the supplied URL pattern.patternBasedFactory
(String urlPattern, String driverClassName, ClassLoader classloader, Field... variables) Create aJdbcConnection.ConnectionFactory
that uses the specific JDBC driver class loaded with the given class loader, and obtains the connection URL by replacing the following variables in the URL pattern:${hostname}
${port}
${dbname}
${username}
${password}
prepareQuery
(String preparedQueryString) Executes a SQL query, preparing it if encountering it for the first time.prepareQuery
(String[] multiQuery, JdbcConnection.StatementPreparer[] preparers, JdbcConnection.BlockingMultiResultSetConsumer resultConsumer) Execute multiple SQL prepared queries where each query is executed with the same set of parameters.prepareQuery
(String[] multiQuery, JdbcConnection.StatementPreparer preparer, JdbcConnection.BlockingMultiResultSetConsumer resultConsumer) Execute multiple SQL prepared queries where each query is executed with the same set of parameters.prepareQuery
(String preparedQueryString, JdbcConnection.StatementPreparer preparer, JdbcConnection.ResultSetConsumer resultConsumer) Execute a SQL prepared query.prepareQuery
(String preparedQueryString, List<?> parameters, JdbcConnection.ParameterResultSetConsumer resultConsumer) Execute a SQL prepared query.<T> T
prepareQueryAndMap
(String preparedQueryString, JdbcConnection.StatementPreparer preparer, JdbcConnection.ResultSetMapper<T> mapper) Execute a SQL prepared query and map the result set into an expected type..prepareQueryWithBlockingConsumer
(String preparedQueryString, JdbcConnection.StatementPreparer preparer, JdbcConnection.BlockingResultSetConsumer resultConsumer) Execute a SQL prepared query.prepareUpdate
(String stmt, JdbcConnection.StatementPreparer preparer) Execute a SQL update via a prepared statement.void
void
private static Properties
query
(String query, JdbcConnection.ResultSetConsumer resultConsumer) Execute a SQL query.query
(String query, JdbcConnection.StatementFactory statementFactory, JdbcConnection.ResultSetConsumer resultConsumer) Execute a SQL query.<T> T
queryAndMap
(String query, JdbcConnection.ResultSetMapper<T> mapper) Execute a SQL query and map the result set into an expected type.<T> T
queryAndMap
(String query, JdbcConnection.StatementFactory statementFactory, JdbcConnection.ResultSetMapper<T> mapper) Execute a SQL query and map the result set into an expected type.static <T> T
querySingleValue
(Connection connection, String queryString, JdbcConnection.StatementPreparer preparer, JdbcConnection.ResultSetExtractor<T> extractor) queryWithBlockingConsumer
(String query, JdbcConnection.StatementFactory statementFactory, JdbcConnection.BlockingResultSetConsumer resultConsumer) quotedColumnIdString
(String columnName) Prepares qualified column names with appropriate quote character as per the specific database's rules.quotedTableIdString
(TableId tableId) Converts a table id into a string with all components of the id quoted so non-alphanumeric characters are properly handled.Get the names of all of the catalogs.readAllSchemaNames
(Predicate<String> filter) Get the names of all of the schemas, optionally applying a filter.readAllTableNames
(String[] tableTypes) Get the identifiers of all available tables.readPrimaryKeyNames
(DatabaseMetaData metadata, TableId id) readPrimaryKeyOrUniqueIndexNames
(DatabaseMetaData metadata, TableId id) void
readSchema
(Tables tables, String databaseCatalog, String schemaNamePattern, Tables.TableFilter tableFilter, Tables.ColumnNameFilter columnFilter, boolean removeTablesNotFoundInJdbc) Create definitions for each tables in the database, given the catalog name, schema pattern, table filter, and column filter.protected Optional<ColumnEditor>
readTableColumn
(ResultSet columnMetadata, TableId tableId, Tables.ColumnNameFilter columnFilter) Returns aColumnEditor
representing the current record of the given result set of column metadata, if included in column.include.list.readTableNames
(String databaseCatalog, String schemaNamePattern, String tableNamePattern, String[] tableTypes) Get the identifiers of the tables.readTablePreparedStatement
(CommonConnectorConfig connectorConfig, String sql, OptionalLong tableSize) Allow per-connector prepared query creation to override for best database performance depending on the table size.readTableStatement
(CommonConnectorConfig connectorConfig, OptionalLong tableSize) Allow per-connector query creation to override for best database performance depending on the table size.readTableUniqueIndices
(DatabaseMetaData metadata, TableId id) protected String
resolveCatalogName
(String catalogName) protected int
resolveJdbcType
(int metadataJdbcType, int nativeType) Resolves the supplied metadata JDBC type to a final JDBC type.protected int
resolveNativeType
(String typeName) Provides a native type for the given type name.rollback()
<T extends DatabaseSchema<TableId>>
Object[]rowToArray
(Table table, T databaseSchema, ResultSet rs, ColumnUtils.ColumnArray columnArray) Converts aResultSet
row to an array of ObjectssetAutoCommit
(boolean autoCommit) singleResultMapper
(JdbcConnection.ResultSetExtractor<T> extractor, String error) String[]
username()
Returns the username for this connection
-
Field Details
-
WAIT_FOR_CLOSE_SECONDS
private static final int WAIT_FOR_CLOSE_SECONDS- See Also:
-
STATEMENT_DELIMITER
private static final char STATEMENT_DELIMITER- See Also:
-
STATEMENT_CACHE_CAPACITY
private static final int STATEMENT_CACHE_CAPACITY- See Also:
-
LOGGER
private static final org.slf4j.Logger LOGGER -
CONNECTION_VALID_CHECK_TIMEOUT_IN_SEC
private static final int CONNECTION_VALID_CHECK_TIMEOUT_IN_SEC- See Also:
-
statementCache
-
config
-
factory
-
initialOps
-
openingQuoteCharacter
-
closingQuoteCharacter
-
conn
-
-
Constructor Details
-
JdbcConnection
public JdbcConnection(JdbcConfiguration config, JdbcConnection.ConnectionFactory connectionFactory, String openingQuoteCharacter, String closingQuoteCharacter) Create a new instance with the given configuration and connection factory.- Parameters:
config
- the configuration; may not be nullconnectionFactory
- the connection factory; may not be null
-
JdbcConnection
public JdbcConnection(JdbcConfiguration config, JdbcConnection.ConnectionFactory connectionFactory, Supplier<ClassLoader> classLoaderSupplier, String openingQuoteCharacter, String closingQuoteCharacter) Create a new instance with the given configuration and connection factory.- Parameters:
config
- the configuration; may not be nullconnectionFactory
- the connection factory; may not be null
-
JdbcConnection
protected JdbcConnection(JdbcConfiguration config, JdbcConnection.ConnectionFactory connectionFactory, JdbcConnection.Operations initialOperations, Supplier<ClassLoader> classLoaderSupplier, String openingQuotingChar, String closingQuotingChar) Create a new instance with the given configuration and connection factory, and specify the operations that should be run against each newly-established connection.- Parameters:
config
- the configuration; may not be nullconnectionFactory
- the connection factory; may not be nullinitialOperations
- the initial operations that should be run on each new connection; may be nullclassLoaderSupplier
- class loader supplieropeningQuotingChar
- the opening quoting characterclosingQuotingChar
- the closing quoting character
-
-
Method Details
-
patternBasedFactory
public static JdbcConnection.ConnectionFactory patternBasedFactory(String urlPattern, Field... variables) Create aJdbcConnection.ConnectionFactory
that replaces variables in the supplied URL pattern. Variables include:${hostname}
${port}
${dbname}
${username}
${password}
- Parameters:
urlPattern
- the URL pattern string; may not be nullvariables
- any custom or overridden configuration variables- Returns:
- the connection factory
-
patternBasedFactory
public static JdbcConnection.ConnectionFactory patternBasedFactory(String urlPattern, String driverClassName, ClassLoader classloader, Field... variables) Create aJdbcConnection.ConnectionFactory
that uses the specific JDBC driver class loaded with the given class loader, and obtains the connection URL by replacing the following variables in the URL pattern:${hostname}
${port}
${dbname}
${username}
${password}
This method attempts to instantiate the JDBC driver class and use that instance to connect to the database.
- Parameters:
urlPattern
- the URL pattern string; may not be nulldriverClassName
- the name of the JDBC driver class; may not be nullclassloader
- the ClassLoader that should be used to load the JDBC driver class given by `driverClassName`; may be null if this class' class loader should be usedvariables
- any custom or overridden configuration variables- Returns:
- the connection factory
-
propsWithMaskedPassword
-
combineVariables
-
findAndReplace
-
findAndReplace
private static String findAndReplace(String url, String name, Properties props, String defaultValue) -
config
Obtain the configuration for this connection.- Returns:
- the JDBC configuration; never null
-
setAutoCommit
- Throws:
SQLException
-
commit
- Throws:
SQLException
-
rollback
- Throws:
SQLException
-
connect
Ensure a connection to the database is established.- Returns:
- this object for chaining methods together
- Throws:
SQLException
- if there is an error connecting to the database
-
execute
Execute a series of SQL statements as a single transaction.- Parameters:
sqlStatements
- the SQL statements that are to be performed as a single transaction- Returns:
- this object for chaining methods together
- Throws:
SQLException
- if there is an error connecting to the database or executing the statements- See Also:
-
execute
Execute a series of operations as a single transaction.- Parameters:
operations
- the function that will be called with a newly-createdStatement
, and that performs one or more operations on that statement object- Returns:
- this object for chaining methods together
- Throws:
SQLException
- if there is an error connecting to the database or executing the statements
-
query
public JdbcConnection query(String query, JdbcConnection.ResultSetConsumer resultConsumer) throws SQLException Execute a SQL query.- Parameters:
query
- the SQL queryresultConsumer
- the consumer of the query results- Returns:
- this object for chaining methods together
- Throws:
SQLException
- if there is an error connecting to the database or executing the statements- See Also:
-
queryAndMap
public <T> T queryAndMap(String query, JdbcConnection.ResultSetMapper<T> mapper) throws SQLException Execute a SQL query and map the result set into an expected type.- Type Parameters:
T
- type returned by the mapper- Parameters:
query
- the SQL querymapper
- the function processing the query results- Returns:
- the result of the mapper calculation
- Throws:
SQLException
- if there is an error connecting to the database or executing the statements- See Also:
-
call
public JdbcConnection call(String sql, JdbcConnection.CallPreparer callPreparer, JdbcConnection.ResultSetConsumer resultSetConsumer) throws SQLException Execute a stored procedure.- Parameters:
sql
- the SQL query; may not benull
callPreparer
- aJdbcConnection.CallPreparer
instance which can be used to set additional parameters; may be nullresultSetConsumer
- aJdbcConnection.ResultSetConsumer
instance which can be used to process the results; may be null- Returns:
- this object for chaining methods together
- Throws:
SQLException
- if anything unexpected fails
-
query
public JdbcConnection query(String query, JdbcConnection.StatementFactory statementFactory, JdbcConnection.ResultSetConsumer resultConsumer) throws SQLException Execute a SQL query.- Parameters:
query
- the SQL querystatementFactory
- the function that should be used to create the statement from the connection; may not be nullresultConsumer
- the consumer of the query results- Returns:
- this object for chaining methods together
- Throws:
SQLException
- if there is an error connecting to the database or executing the statements- See Also:
-
prepareQuery
public JdbcConnection prepareQuery(String[] multiQuery, JdbcConnection.StatementPreparer preparer, JdbcConnection.BlockingMultiResultSetConsumer resultConsumer) throws SQLException, InterruptedException Execute multiple SQL prepared queries where each query is executed with the same set of parameters.- Parameters:
multiQuery
- the array of prepared queriespreparer
- the function that supplies arguments to the prepared statement; may not be nullresultConsumer
- the consumer of the query results- Returns:
- this object for chaining methods together
- Throws:
SQLException
- if there is an error connecting to the database or executing the statementsInterruptedException
- See Also:
-
prepareQuery
public JdbcConnection prepareQuery(String[] multiQuery, JdbcConnection.StatementPreparer[] preparers, JdbcConnection.BlockingMultiResultSetConsumer resultConsumer) throws SQLException, InterruptedException Execute multiple SQL prepared queries where each query is executed with the same set of parameters.- Parameters:
multiQuery
- the array of prepared queriespreparers
- the array of functions that supply arguments to the prepared statements; may not be nullresultConsumer
- the consumer of the query results- Returns:
- this object for chaining methods together
- Throws:
SQLException
- if there is an error connecting to the database or executing the statementsInterruptedException
- See Also:
-
queryAndMap
public <T> T queryAndMap(String query, JdbcConnection.StatementFactory statementFactory, JdbcConnection.ResultSetMapper<T> mapper) throws SQLException Execute a SQL query and map the result set into an expected type.- Type Parameters:
T
- type returned by the mapper- Parameters:
query
- the SQL querystatementFactory
- the function that should be used to create the statement from the connection; may not be nullmapper
- the function processing the query results- Returns:
- the result of the mapper calculation
- Throws:
SQLException
- if there is an error connecting to the database or executing the statements- See Also:
-
queryWithBlockingConsumer
public JdbcConnection queryWithBlockingConsumer(String query, JdbcConnection.StatementFactory statementFactory, JdbcConnection.BlockingResultSetConsumer resultConsumer) throws SQLException, InterruptedException - Throws:
SQLException
InterruptedException
-
prepareQueryWithBlockingConsumer
public JdbcConnection prepareQueryWithBlockingConsumer(String preparedQueryString, JdbcConnection.StatementPreparer preparer, JdbcConnection.BlockingResultSetConsumer resultConsumer) throws SQLException, InterruptedException Execute a SQL prepared query.- Parameters:
preparedQueryString
- the prepared query stringpreparer
- the function that supplied arguments to the prepared statement; may not be nullresultConsumer
- the consumer of the query results- Returns:
- this object for chaining methods together
- Throws:
SQLException
- if there is an error connecting to the database or executing the statementsInterruptedException
- See Also:
-
prepareQuery
Executes a SQL query, preparing it if encountering it for the first time.- Parameters:
preparedQueryString
- the prepared query string- Returns:
- this object for chaining methods together
- Throws:
SQLException
- if there is an error connecting to the database or executing the statements
-
prepareQuery
public JdbcConnection prepareQuery(String preparedQueryString, JdbcConnection.StatementPreparer preparer, JdbcConnection.ResultSetConsumer resultConsumer) throws SQLException Execute a SQL prepared query.- Parameters:
preparedQueryString
- the prepared query stringpreparer
- the function that supplied arguments to the prepared statement; may not be nullresultConsumer
- the consumer of the query results- Returns:
- this object for chaining methods together
- Throws:
SQLException
- if there is an error connecting to the database or executing the statements- See Also:
-
prepareQueryAndMap
public <T> T prepareQueryAndMap(String preparedQueryString, JdbcConnection.StatementPreparer preparer, JdbcConnection.ResultSetMapper<T> mapper) throws SQLException Execute a SQL prepared query and map the result set into an expected type..- Type Parameters:
T
- type returned by the mapper- Parameters:
preparedQueryString
- the prepared query stringpreparer
- the function that supplied arguments to the prepared statement; may not be nullmapper
- the function processing the query results- Returns:
- the result of the mapper calculation
- Throws:
SQLException
- if there is an error connecting to the database or executing the statements- See Also:
-
prepareUpdate
public JdbcConnection prepareUpdate(String stmt, JdbcConnection.StatementPreparer preparer) throws SQLException Execute a SQL update via a prepared statement.- Parameters:
stmt
- the statement stringpreparer
- the function that supplied arguments to the prepared stmt; may be null- Returns:
- this object for chaining methods together
- Throws:
SQLException
- if there is an error connecting to the database or executing the statements- See Also:
-
prepareQuery
public JdbcConnection prepareQuery(String preparedQueryString, List<?> parameters, JdbcConnection.ParameterResultSetConsumer resultConsumer) throws SQLException Execute a SQL prepared query.- Parameters:
preparedQueryString
- the prepared query stringparameters
- the list of values for parameters in the query; may not be nullresultConsumer
- the consumer of the query results- Returns:
- this object for chaining methods together
- Throws:
SQLException
- if there is an error connecting to the database or executing the statements- See Also:
-
print
-
print
-
delimiter
-
findMaxLength
- Throws:
SQLException
-
isConnected
- Throws:
SQLException
-
isValid
- Throws:
SQLException
-
connection
- Throws:
SQLException
-
connection
- Throws:
SQLException
-
parseSqlStatementString
-
close
Close the connection and release any resources.- Specified by:
close
in interfaceAutoCloseable
- Throws:
SQLException
-
doClose
- Throws:
SQLException
-
readAllCatalogNames
Get the names of all of the catalogs.- Returns:
- the set of catalog names; never null but possibly empty
- Throws:
SQLException
- if an error occurs while accessing the database metadata
-
readAllSchemaNames
Get the names of all of the schemas, optionally applying a filter.- Parameters:
filter
- aPredicate
to test each schema name; may be null in which case all schema names are returned- Returns:
- the set of catalog names; never null but possibly empty
- Throws:
SQLException
- if an error occurs while accessing the database metadata
-
tableTypes
- Throws:
SQLException
-
readAllTableNames
Get the identifiers of all available tables.- Parameters:
tableTypes
- the set of table types to include in the results, which may be null for all table types- Returns:
- the set of
TableId
s; never null but possibly empty - Throws:
SQLException
- if an error occurs while accessing the database metadata
-
readTableNames
public Set<TableId> readTableNames(String databaseCatalog, String schemaNamePattern, String tableNamePattern, String[] tableTypes) throws SQLException Get the identifiers of the tables.- Parameters:
databaseCatalog
- the name of the catalog, which is typically the database name; may be an empty string for tables that have no catalog, ornull
if the catalog name should not be used to narrow the list of table identifiersschemaNamePattern
- the pattern used to match database schema names, which may be "" to match only those tables with no schema ornull
if the schema name should not be used to narrow the list of table identifierstableNamePattern
- the pattern used to match database table names, which may be null to match all table namestableTypes
- the set of table types to include in the results, which may be null for all table types- Returns:
- the set of
TableId
s; never null but possibly empty - Throws:
SQLException
- if an error occurs while accessing the database metadata
-
connectionString
Returns a JDBC connection string using the current configuration and url.- Parameters:
urlPattern
- aString
representing a JDBC connection with variables that will be replaced- Returns:
- a
String
where the variables inurlPattern
are replaced with values from the configuration
-
username
Returns the username for this connection- Returns:
- a
String
, nevernull
-
database
Returns the database name for this connection- Returns:
- a
String
, nevernull
-
resolveNativeType
Provides a native type for the given type name. There isn't a standard way to obtain this information via JDBC APIs so this method exists to allow database specific information to be set in addition to the JDBC Type.- Parameters:
typeName
- the name of the type whose native type we are looking for- Returns:
- A type constant for the specific database or -1.
-
resolveJdbcType
protected int resolveJdbcType(int metadataJdbcType, int nativeType) Resolves the supplied metadata JDBC type to a final JDBC type.- Parameters:
metadataJdbcType
- the JDBC type from the underlying driver's metadata lookupnativeType
- the database native type or -1 for unknown- Returns:
- the resolved JDBC type
-
readSchema
public void readSchema(Tables tables, String databaseCatalog, String schemaNamePattern, Tables.TableFilter tableFilter, Tables.ColumnNameFilter columnFilter, boolean removeTablesNotFoundInJdbc) throws SQLException Create definitions for each tables in the database, given the catalog name, schema pattern, table filter, and column filter.- Parameters:
tables
- the set of table definitions to be modified; may not be nulldatabaseCatalog
- the name of the catalog, which is typically the database name; may be null if all accessible databases are to be processedschemaNamePattern
- the pattern used to match database schema names, which may be "" to match only those tables with no schema or null to process all accessible tables regardless of database schema nametableFilter
- used to determine for which tables are to be processed; may be null if all accessible tables are to be processedcolumnFilter
- used to determine which columns should be included as fields in its table's definition; may be null if all columns for all tables are to be includedremoveTablesNotFoundInJdbc
-true
if this method should remove fromtables
any definitions for tables that are not found in the database metadata, orfalse
if such tables should be left untouched- Throws:
SQLException
- if an error occurs while accessing the database metadata
-
resolveCatalogName
-
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 - Throws:
SQLException
-
readTableColumn
protected Optional<ColumnEditor> readTableColumn(ResultSet columnMetadata, TableId tableId, Tables.ColumnNameFilter columnFilter) throws SQLException Returns aColumnEditor
representing the current record of the given result set of column metadata, if included in column.include.list.- Throws:
SQLException
-
overrideColumn
Allow implementations an opportunity to adjust the current state of theColumnEditor
that has been seeded with data from the column metadata from the JDBC driver. In some cases, the data from the driver may be misleading and needs some adjustments.- Parameters:
column
- the column editor, should not benull
- Returns:
- the adjusted column editor instance
-
readPrimaryKeyNames
- Throws:
SQLException
-
readTableUniqueIndices
public List<String> readTableUniqueIndices(DatabaseMetaData metadata, TableId id) throws SQLException - Throws:
SQLException
-
readPrimaryKeyOrUniqueIndexNames
protected List<String> readPrimaryKeyOrUniqueIndexNames(DatabaseMetaData metadata, TableId id) throws SQLException - Throws:
SQLException
-
isTableUniqueIndexIncluded
Allows the connector implementation to determine if a table's unique index should be include when resolving a table's unique indices.- Parameters:
indexName
- the index namecolumnName
- the column name- Returns:
- true if the index is to be included; false otherwise.
-
cleanupPreparedStatement
-
createPreparedStatement
-
executeWithoutCommitting
Executes a series of statements without explicitly committing the connection.- Parameters:
statements
- a series of statements to execute- Returns:
- this object so methods can be chained together; never null
- Throws:
SQLException
- if anything fails
-
isNullable
protected static boolean isNullable(int jdbcNullable) -
singleResultMapper
public <T> JdbcConnection.ResultSetMapper<T> singleResultMapper(JdbcConnection.ResultSetExtractor<T> extractor, String error) throws SQLException - Throws:
SQLException
-
querySingleValue
public static <T> T querySingleValue(Connection connection, String queryString, JdbcConnection.StatementPreparer preparer, JdbcConnection.ResultSetExtractor<T> extractor) throws SQLException - Throws:
SQLException
-
buildSelectWithRowLimits
-
readTableStatement
public Statement readTableStatement(CommonConnectorConfig connectorConfig, OptionalLong tableSize) throws SQLException Allow per-connector query creation to override for best database performance depending on the table size.- Throws:
SQLException
-
readTablePreparedStatement
public PreparedStatement readTablePreparedStatement(CommonConnectorConfig connectorConfig, String sql, OptionalLong tableSize) throws SQLException Allow per-connector prepared query creation to override for best database performance depending on the table size.- Throws:
SQLException
-
getColumnValue
public <T extends DatabaseSchema<TableId>> Object getColumnValue(ResultSet rs, int columnIndex, Column column, Table table, T schema) throws SQLException Reads a value from JDBC result set and execute per-connector conversion if needed- Throws:
SQLException
-
rowToArray
public <T extends DatabaseSchema<TableId>> Object[] rowToArray(Table table, T databaseSchema, ResultSet rs, ColumnUtils.ColumnArray columnArray) throws SQLException Converts aResultSet
row to an array of Objects- Throws:
SQLException
-
quotedTableIdString
Converts a table id into a string with all components of the id quoted so non-alphanumeric characters are properly handled.- Parameters:
tableId
-- Returns:
- formatted string
-
quotedColumnIdString
Prepares qualified column names with appropriate quote character as per the specific database's rules. -
loadKeyStore
Read JKS type keystore/truststore file according related password.
-