java.lang.Object
com.pervasive.datarush.jdbc.JDBCConnector
- All Implemented Interfaces:
ConnectionSettings
Basic JDBC connector class. Stores information required to create new JDBC
connections and provides various common utility methods.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClose all resources opened during getConnection()voidcloseResultSetAndStatement(String statement, ResultSet rs) Closes a result set object.voidcloseStatement(String statement, PreparedStatement s) Closes a prepared statement object.executeAndLogSql(String statement, boolean haltOnError, int fetchSize) Executes a given SQL statement, returning the result.voidexecuteAndLogStatement(String statement) Executes the given statement closing the result set when finished.Creates a JDBC connection as necessary and returns it.Returns the connection factory to be used for creating connections.Get the delimiter character.Retrieves the class name of the JDBC driver to use.Get the list of configured database host names.Gets the database metadata associated with this connection.Retrieves the password for connecting to the database.Gets the metadata associated with this connection's table.getTableMetadata(String statement) Gets the metadata associated with the provided statementRetrieves the name of the database table to access.getUrl()Retrieves the URL for connecting to the database.getUser()Retrieves the user name for connecting to the database.voidsetConnectionFactory(ConnectionFactory connectionFactory) Sets the connection factory to be used for creating connections.voidsetDelimiter(String delimiter) Set the delimiter character used to delimiter table names in SQL queries.voidsetDriverName(String driverName) Sets the class name of the JDBC driver to use, for example:"sun.jdbc.odbc.JdbcOdbcDriver".voidsetEncryyptedPassword(Password password) voidsetHostNames(String... hostNames) Set the list of database host names that can be used to execute queries.voidsetHostNames(List<String> hostNames) Set the list of database host names that can be used to execute queries.voidsetPassword(String password) Sets the password for connecting to the database.voidsetTableName(String tableName) Sets the name of the database table to access.voidSets the URL for connecting to the database, for example:jdbc:odbc:SampleTest.voidSets the user name for connecting to the database.booleanDetermine if the table associated with the connection exists
-
Constructor Details
-
JDBCConnector
public JDBCConnector()
-
-
Method Details
-
setDriverName
Sets the class name of the JDBC driver to use, for example:"sun.jdbc.odbc.JdbcOdbcDriver".- Parameters:
driverName- the class name of the JDBC driver to use
-
getDriverName
Retrieves the class name of the JDBC driver to use.- Specified by:
getDriverNamein interfaceConnectionSettings- Returns:
- the class name of the JDBC driver to use
-
setUser
Sets the user name for connecting to the database.- Parameters:
user- the user name for connecting to the database
-
getUser
Retrieves the user name for connecting to the database.- Specified by:
getUserin interfaceConnectionSettings- Returns:
- the user name for connecting to the database
-
setPassword
Sets the password for connecting to the database.- Parameters:
password- the password for connecting to the database
-
setEncryyptedPassword
-
getPassword
Retrieves the password for connecting to the database.- Specified by:
getPasswordin interfaceConnectionSettings- Returns:
- the password for connecting to the database
-
getEncryptedPassword
-
setUrl
Sets the URL for connecting to the database, for example:jdbc:odbc:SampleTest.- Parameters:
url- the URL for connecting to the database
-
getUrl
Retrieves the URL for connecting to the database.- Specified by:
getUrlin interfaceConnectionSettings- Returns:
- the URL for connecting to the database
-
getTableName
Retrieves the name of the database table to access.- Returns:
- the name of the database table to access
-
setTableName
Sets the name of the database table to access. The table name is required byWriteToJDBC, but optional forReadFromJDBC, sinceReadFromJDBC#setSelectStatement(String)may be used instead.- Parameters:
tableName- the name of the database table to access
-
getHostNames
Get the list of configured database host names.- Returns:
- database host names
-
setHostNames
Set the list of database host names that can be used to execute queries. This is an optional parameter this is only valid for databases that support multiple database hosts for executing queries.- Parameters:
hostNames- list of database host names
-
setHostNames
Set the list of database host names that can be used to execute queries. This is an optional parameter this is only valid for databases that support multiple database hosts for executing queries.- Parameters:
hostNames- list of database host names
-
setConnectionFactory
Sets the connection factory to be used for creating connections. Defaults toDefaultConnectionFactory.- Parameters:
connectionFactory- the connection factory to be used for creating connections.
-
getConnectionFactory
Returns the connection factory to be used for creating connections. Defaults toDefaultConnectionFactory.- Returns:
- the connection factory to be used for creating connections.
-
getDelimiter
Get the delimiter character.- Returns:
- delimiter character
-
setDelimiter
Set the delimiter character used to delimiter table names in SQL queries.- Parameters:
delimiter- delimiter character used to surround table names
-
getConnection
Creates a JDBC connection as necessary and returns it. This is the connection object that is used by all utility methods. If a new connection is required create one using the factory provided by thegetConnectionFactory()method.- Returns:
- JDBC connection
-
cleanupConnection
public void cleanupConnection()Close all resources opened during getConnection()- See Also:
-
getMetadata
Gets the database metadata associated with this connection.- Returns:
- a DatabaseMetaData object associated with this connection
-
getTableMetadata
Gets the metadata associated with this connection's table.- Returns:
- a ResultSetMetaData object associated with this connection's table
-
getTableMetadata
Gets the metadata associated with the provided statement- Returns:
- a ResultSetMetaData object associated with the statement
-
tableExists
public boolean tableExists()Determine if the table associated with the connection exists- Returns:
- true if the table exists
-
executeAndLogStatement
Executes the given statement closing the result set when finished.- Parameters:
statement- the statement to execute
-
executeAndLogSql
Executes a given SQL statement, returning the result. Caller is responsible for freeing the result set.- Parameters:
statement- the statement to executehaltOnError- if true an error will be thrown if a SQLException is encounteredfetchSize- the fetch size to use with thePreparedStatement- Returns:
- the result set
-
closeStatement
Closes a prepared statement object.- Parameters:
statement- the original SQL statements- the prepared statement to close
-
closeResultSetAndStatement
Closes a result set object.- Parameters:
statement- the original SQL statementrs- the result set to close
-