com.univocity.api.entity.jdbc
Class JdbcDataStoreConfiguration

java.lang.Object
  extended by com.univocity.api.entity.custom.DataStoreConfiguration
      extended by com.univocity.api.entity.jdbc.JdbcDataStoreConfiguration

public final class JdbcDataStoreConfiguration
extends DataStoreConfiguration

The JDBC data store configuration class. Use it to configure the JDBC data entities and queries that will be manipulated by a DataIntegrationEngine.

Author:
uniVocity Software Pty Ltd - dev@univocity.com
See Also:
JdbcEntityConfiguration, JdbcQueryConfiguration, DataSource

Constructor Summary
JdbcDataStoreConfiguration(String dataStoreName, DataSource dataSource)
          Creates a new JDBC data store configuration
 
Method Summary
 JdbcQueryConfiguration addQuery(File queryFile)
          Creates a new SQL query entity from a file and adds it to this data store.
 JdbcQueryConfiguration addQuery(File queryFile, Charset encoding)
          Creates a new SQL query entity from a file and adds it to this data store.
 JdbcQueryConfiguration addQuery(File queryFile, String encoding)
          Creates a new SQL query entity from a file and adds it to this data store.
 JdbcQueryConfiguration addQuery(String queryName, File queryFile)
          Creates a new SQL query entity from a file and adds it to this data store.
 JdbcQueryConfiguration addQuery(String queryName, File queryFile, Charset encoding)
          Creates a new SQL query entity from a file and adds it to this data store.
 JdbcQueryConfiguration addQuery(String queryName, File queryFile, String encoding)
          Creates a new SQL query entity from a file and adds it to this data store.
 JdbcQueryConfiguration addQuery(String queryName, String query)
          Creates a new SQL query entity and adds it to this data store.
 JdbcQueryConfiguration addQueryFromResource(String queryName, String resourcePath)
          Creates a new SQL query entity from a resource and adds it to this data store.
 JdbcQueryConfiguration addQueryFromResource(String name, String resourcePath, Charset encoding)
          Creates a new SQL query entity from a resource and adds it to this data store.
 JdbcQueryConfiguration addQueryFromResource(String queryName, String resourcePath, String encoding)
          Creates a new SQL query entity from a resource and adds it to this data store.
 void addReservedWordsToEscape(Collection<String> reservedWords)
          Adds user-defined reserved words that might conflict with table and column names in SQL statements.
 void addReservedWordsToEscape(String... reservedWords)
          Adds user-defined reserved words that might conflict with table and column names in SQL statements.
 void enableDatabaseOperationsIn(Collection<String> entityNames)
          Has no effect over JDBC data entities as they already support database operations.
 void enableDatabaseOperationsIn(String... tableNames)
          Has no effect over JDBC data entities as they already support database operations.
 String getCatalog()
          Obtains the catalog name that should be used to refer to elements of the database managed by this JDBC data store.
 Set<String> getDatabaseEnabledEntities()
          Returns an empty set as JDBC data entities already support database operations.
 DatabaseCapabilities getDatabaseInformation()
          Obtains an object describing the capabilities of the database managed by this JDBC data store.
 DataSource getDataSource()
          Obtains the DataSource used to connect to the managed JDBC data entities.
 JdbcEntityConfiguration getDefaultEntityConfiguration()
          Returns the default configuration object for JDBC data entities.
 JdbcQueryConfiguration getDefaultQueryConfiguration()
          Returns the default configuration object for JDBC query entities.
 DatabaseDialect getDialect()
          Returns the dialect of this database.
 JdbcEntityConfiguration getEntityConfiguration(String tableName)
          Returns the configuration of a given data entity.
 IdentifierEscaper getIdentifierEscaper()
          Returns the user-defined IdentifierEscaper configured to handle reserved word escaping when SQL statements are generated.
 int getLimitOfRowsLoadedInMemory()
          Obtains the maximum number of rows loaded in memory at a time when extracting information from entities and queries in this data store.
 JdbcQueryConfiguration getQueryConfiguration(String queryName)
          Returns the configuration of a given query entity.
 Collection<String> getReservedWordsToEscape()
          Returns the collection of user-defined reserved words provided with addReservedWordsToEscape(String...).
 String getSchema()
          Obtains the schema name that should be used to refer to elements of the database managed by this JDBC data store.
 int getTransactionIsolationLevel()
          Obtains the transaction isolation level used when persisting data into entities of this data store.
 int getTransactionTimeout()
          Obtains the timeout, in number of seconds, for transactions created from this data store.
 void setCatalog(String catalog)
          Defines the catalog name that should be used to refer to elements of the database managed by this JDBC data store.
 void setDatabaseInformation(DatabaseCapabilities databaseInformation)
          Defines the capabilities of the database managed by this JDBC data store.
 void setDialect(DatabaseDialect dialect)
          Defines the dialect of this database.
 void setIdentifierEscaper(IdentifierEscaper escape)
          Provides a user-defined IdentifierEscaper to handle reserved word escaping when generating SQL statements.
 void setLimitOfRowsLoadedInMemory(int rowLimit)
          Defines the maximum number of rows loaded in memory at a time when extracting information from entities and queries in this data store.
 void setSchema(String schema)
          Defines the schema name that should be used to refer to elements of the database managed by this JDBC data store.
 void setTransactionIsolationLevel(int transactionIsolationLevel)
          Defines the transaction isolation level used when persisting data into entities of this data store.
 void setTransactionTimeout(int transactionTimeout)
          Defines a timeout, in number of seconds, for transactions created from this data store.
 
Methods inherited from class com.univocity.api.entity.custom.DataStoreConfiguration
getDataStoreName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcDataStoreConfiguration

public JdbcDataStoreConfiguration(String dataStoreName,
                                  DataSource dataSource)
Creates a new JDBC data store configuration

Parameters:
dataStoreName - the name of the JDBC data store.
dataSource - the DataSource used to connect to the underlying database.
Method Detail

getDataSource

public final DataSource getDataSource()
Obtains the DataSource used to connect to the managed JDBC data entities.

Returns:
the DataSource

getSchema

public final String getSchema()
Obtains the schema name that should be used to refer to elements of the database managed by this JDBC data store.

Returns:
the schema

setSchema

public final void setSchema(String schema)
Defines the schema name that should be used to refer to elements of the database managed by this JDBC data store.

Parameters:
schema - the schema name

getCatalog

public final String getCatalog()
Obtains the catalog name that should be used to refer to elements of the database managed by this JDBC data store.

Returns:
the catalog

setCatalog

public final void setCatalog(String catalog)
Defines the catalog name that should be used to refer to elements of the database managed by this JDBC data store.

Parameters:
catalog - the catalog name

getDatabaseInformation

public final DatabaseCapabilities getDatabaseInformation()
Obtains an object describing the capabilities of the database managed by this JDBC data store.

By default, uniVocity tries to detect this information automatically.

Returns:
the database capabilities information

setDatabaseInformation

public final void setDatabaseInformation(DatabaseCapabilities databaseInformation)
Defines the capabilities of the database managed by this JDBC data store.

By default, uniVocity tries to detect this information automatically. The configuration you set here takes precedence over any auto-detected data.

Parameters:
databaseInformation - the database information.

getEntityConfiguration

public final JdbcEntityConfiguration getEntityConfiguration(String tableName)
Returns the configuration of a given data entity. The returned configuration object will contain default values provided in the object returned by getDefaultEntityConfiguration().
If the entity was not explicitly configured before, a new configuration object will be created and associated with the entity.

You can change the default configuration at any time by calling getDefaultEntityConfiguration() and altering the settings you need. Subsequent calls to getEntityConfiguration(String) will return a configuration object with the new defaults. Existing configurations will retain their original values, including the default settings previously used.

Parameters:
tableName - the name of the entity to be configured
Returns:
a configuration object for the given data entity.

getDefaultEntityConfiguration

public final JdbcEntityConfiguration getDefaultEntityConfiguration()
Returns the default configuration object for JDBC data entities. This object returns all default values used for creating new configuration objects for data entities.

Returns:
the defaultEntityConfiguration object.

getDefaultQueryConfiguration

public final JdbcQueryConfiguration getDefaultQueryConfiguration()
Returns the default configuration object for JDBC query entities. This object returns all default values used for creating new configuration objects for query entities.

Returns:
the defaultQueryConfiguration object.

addQueryFromResource

public final JdbcQueryConfiguration addQueryFromResource(String queryName,
                                                         String resourcePath)
Creates a new SQL query entity from a resource and adds it to this data store. The resource path can be a file in the class path or in the file system.

Parameters:
queryName - the name of the query
resourcePath - the path to a resource that contains an SQL query. Parameters must be prefixed with a colon, for example: SELECT col_1, col2 FROM table WHERE col_1 = :param_1 OR col_2 = :param_2

Note: As the resource encoding is not provided, the default system encoding will be used.

Returns:
a configuration object for the new query.

addQueryFromResource

public final JdbcQueryConfiguration addQueryFromResource(String queryName,
                                                         String resourcePath,
                                                         String encoding)
Creates a new SQL query entity from a resource and adds it to this data store. The resource path can be a file in the class path or in the file system.

Parameters:
queryName - the name of the query
resourcePath - the path to a resource that contains an SQL query. Parameters must be prefixed with a colon, for example: SELECT col_1, col2 FROM table WHERE col_1 = :param_1 OR col_2 = :param_2
encoding - the encoding of the resource
Returns:
a configuration object for the new query.

addQueryFromResource

public final JdbcQueryConfiguration addQueryFromResource(String name,
                                                         String resourcePath,
                                                         Charset encoding)
Creates a new SQL query entity from a resource and adds it to this data store. The resource path can be a file in the class path or in the file system.

Parameters:
name - queryName the name of the query
resourcePath - the path to a resource that contains an SQL query. Parameters must be prefixed with a colon, for example: SELECT col_1, col2 FROM table WHERE col_1 = :param_1 OR col_2 = :param_2
encoding - the encoding of the resource
Returns:
a configuration object for the new query.

addQuery

public final JdbcQueryConfiguration addQuery(File queryFile)
Creates a new SQL query entity from a file and adds it to this data store. The file name will be used as the query name.

Parameters:
queryFile - a text file containing an SQL query. Parameters must be prefixed with a colon, for example: SELECT col_1, col2 FROM table WHERE col_1 = :param_1 OR col_2 = :param_2

Note: As the encoding of the query file is not provided, the default system encoding will be used.

Returns:
a configuration object for the new query.

addQuery

public final JdbcQueryConfiguration addQuery(File queryFile,
                                             String encoding)
Creates a new SQL query entity from a file and adds it to this data store. The file name will be used as the query name.

Parameters:
queryFile - a text file containing an SQL query. Parameters must be prefixed with a colon, for example: SELECT col_1, col2 FROM table WHERE col_1 = :param_1 OR col_2 = :param_2
encoding - the file encoding
Returns:
a configuration object for the new query.

addQuery

public final JdbcQueryConfiguration addQuery(File queryFile,
                                             Charset encoding)
Creates a new SQL query entity from a file and adds it to this data store. The file name will be used as the query name.

Parameters:
queryFile - a text file containing an SQL query. Parameters must be prefixed with a colon, for example: SELECT col_1, col2 FROM table WHERE col_1 = :param_1 OR col_2 = :param_2
encoding - the file encoding
Returns:
a configuration object for the new query.

addQuery

public final JdbcQueryConfiguration addQuery(String queryName,
                                             File queryFile)
Creates a new SQL query entity from a file and adds it to this data store.

Parameters:
queryName - the name of the query
queryFile - a text file containing an SQL query. Parameters must be prefixed with a colon, for example: SELECT col_1, col2 FROM table WHERE col_1 = :param_1 OR col_2 = :param_2

Note: As the encoding of the query file is not provided, the default system encoding will be used.

Returns:
a configuration object for the new query.

addQuery

public final JdbcQueryConfiguration addQuery(String queryName,
                                             File queryFile,
                                             String encoding)
Creates a new SQL query entity from a file and adds it to this data store.

Parameters:
queryName - the name of the query
queryFile - a text file containing an SQL query. Parameters must be prefixed with a colon, for example: SELECT col_1, col2 FROM table WHERE col_1 = :param_1 OR col_2 = :param_2
encoding - the file encoding
Returns:
a configuration object for the new query.

addQuery

public final JdbcQueryConfiguration addQuery(String queryName,
                                             File queryFile,
                                             Charset encoding)
Creates a new SQL query entity from a file and adds it to this data store.

Parameters:
queryName - the name of the query
queryFile - a text file containing an SQL query. Parameters must be prefixed with a colon, for example: SELECT col_1, col2 FROM table WHERE col_1 = :param_1 OR col_2 = :param_2
encoding - the file encoding
Returns:
a configuration object for the new query.

addQuery

public final JdbcQueryConfiguration addQuery(String queryName,
                                             String query)
Creates a new SQL query entity and adds it to this data store.

Parameters:
queryName - the name of the query
query - the SQL query. Parameters must be prefixed with a colon, for example: SELECT col_1, col2 FROM table WHERE col_1 = :param_1 OR col_2 = :param_2
Returns:
a configuration object for the new query.

getQueryConfiguration

public final JdbcQueryConfiguration getQueryConfiguration(String queryName)
Returns the configuration of a given query entity. The returned configuration object will contain default values provided in the object returned by getDefaultQueryConfiguration().
If the query was not explicitly configured before, a new configuration object will be created and associated with it.

You can change the default configuration at any time by calling getDefaultQueryConfiguration() and altering the settings you need. Subsequent calls to getQueryConfiguration(String) will return a configuration object with the new defaults. Existing configurations will retain their original values, including the default settings previously used.

Parameters:
queryName - the name of the query to be configured
Returns:
a configuration object for the given query entity.

getTransactionTimeout

public final int getTransactionTimeout()
Obtains the timeout, in number of seconds, for transactions created from this data store.

Transactions will be created automatically by uniVocity while performing data mapping operations to this data store.
A new transaction will be created for each mapping cycle started with DataIntegrationEngine.executeCycle().

Defaults to -1 (no timeout)

Returns:
the transaction timeout.

setTransactionTimeout

public final void setTransactionTimeout(int transactionTimeout)
Defines a timeout, in number of seconds, for transactions created from this data store.

Transactions will be created automatically by uniVocity while performing data mapping operations to this data store.
A new transaction will be created for each mapping cycle started with DataIntegrationEngine.executeCycle().

Parameters:
transactionTimeout - the transaction timeout.

getTransactionIsolationLevel

public final int getTransactionIsolationLevel()
Obtains the transaction isolation level used when persisting data into entities of this data store.
The transaction isolation level code returned by this method is passed on to Connection.setTransactionIsolation(int) before mapping data to an entity.

Defaults to Connection.TRANSACTION_REPEATABLE_READ

Returns:
the transaction isolation level

setTransactionIsolationLevel

public final void setTransactionIsolationLevel(int transactionIsolationLevel)
Defines the transaction isolation level used when persisting data into entities of this data store.
The transaction isolation level code returned by this method is passed on to Connection.setTransactionIsolation(int) before mapping data to an entity.

Only the constants defined in Connection are accepted.

Parameters:
transactionIsolationLevel - the transaction isolation level

getLimitOfRowsLoadedInMemory

public final int getLimitOfRowsLoadedInMemory()
Obtains the maximum number of rows loaded in memory at a time when extracting information from entities and queries in this data store.

This number is obtained from default fetch size in getDefaultEntityConfiguration().

Defaults to 10,000 rows

Specified by:
getLimitOfRowsLoadedInMemory in class DataStoreConfiguration
Returns:
the maximum number of rows kept in memory at any given time when reading values from any entity or query of this data store.

setLimitOfRowsLoadedInMemory

public final void setLimitOfRowsLoadedInMemory(int rowLimit)
Defines the maximum number of rows loaded in memory at a time when extracting information from entities and queries in this data store.

This number modifies the default fetch size in getDefaultEntityConfiguration() and getDefaultQueryConfiguration().
The fetch size of already configured entities and queries won't be modified.

Parameters:
rowLimit - the maximum number of rows kept in memory at any given time when reading values from any entity or query of this data store.

addReservedWordsToEscape

public final void addReservedWordsToEscape(String... reservedWords)
Adds user-defined reserved words that might conflict with table and column names in SQL statements.

When generating SQL, an IdentifierEscaper will handle name conflicts and escape any table or column names that are part of potential reserved words.

uniVocity already escapes most common reserved words used by different database vendors. Use this method to provide any additional reserved words.

Parameters:
reservedWords - additional reserved words to escape.

addReservedWordsToEscape

public final void addReservedWordsToEscape(Collection<String> reservedWords)
Adds user-defined reserved words that might conflict with table and column names in SQL statements.

When generating SQL, an IdentifierEscaper will handle name conflicts and escape any table or column names that are part of potential reserved words.

uniVocity already escapes most common reserved words used by different database vendors. Use this method to provide any additional reserved words.

Parameters:
reservedWords - additional reserved words to escape.

getReservedWordsToEscape

public final Collection<String> getReservedWordsToEscape()
Returns the collection of user-defined reserved words provided with addReservedWordsToEscape(String...).

Returns:
an unmodifiable collection of reserved words.

setIdentifierEscaper

public final void setIdentifierEscaper(IdentifierEscaper escape)
Provides a user-defined IdentifierEscaper to handle reserved word escaping when generating SQL statements.

This will override uniVocity's default implementation that escapes reserved words by enclosing them within double quotes(e.g. "escaped identifier").

Parameters:
escape - a custom implementation of IdentifierEscaper

getIdentifierEscaper

public final IdentifierEscaper getIdentifierEscaper()
Returns the user-defined IdentifierEscaper configured to handle reserved word escaping when SQL statements are generated.

Returns:
a custom implementation of IdentifierEscaper, or null if uniVocity's default implementation should be used.

enableDatabaseOperationsIn

public final void enableDatabaseOperationsIn(String... tableNames)
Has no effect over JDBC data entities as they already support database operations.

Overrides:
enableDatabaseOperationsIn in class DataStoreConfiguration
Parameters:
tableNames - the entity names that must have their data loaded into an in-memory database managed by uniVocity

enableDatabaseOperationsIn

public final void enableDatabaseOperationsIn(Collection<String> entityNames)
Has no effect over JDBC data entities as they already support database operations.

Overrides:
enableDatabaseOperationsIn in class DataStoreConfiguration
Parameters:
entityNames - the entity names that must have their data loaded into an in-memory database managed by uniVocity

getDatabaseEnabledEntities

public final Set<String> getDatabaseEnabledEntities()
Returns an empty set as JDBC data entities already support database operations.

Overrides:
getDatabaseEnabledEntities in class DataStoreConfiguration
Returns:
a unmodifiable set containing the database-enabled entity names.

getDialect

public DatabaseDialect getDialect()
Returns the dialect of this database. Used to generate entities (tables) dynamically when required.

Returns:
the dialect of this database.

setDialect

public void setDialect(DatabaseDialect dialect)
Defines the dialect of this database. Used to generate entities (tables) dynamically when required.

Parameters:
dialect - the dialect of this database.


Copyright © 2015 uniVocity Software Pty Ltd. All rights reserved.