- java.lang.Object
 - 
- com.pervasive.datarush.jdbc.JDBCConnector
 
 
- 
- All Implemented Interfaces:
 ConnectionSettings
public class JDBCConnector extends Object implements ConnectionSettings
Basic JDBC connector class. Stores information required to create new JDBC connections and provides various common utility methods. 
- 
- 
Constructor Summary
Constructors Constructor Description JDBCConnector() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanupConnection()Close 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.ResultSetexecuteAndLogSql(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.ConnectiongetConnection()Creates a JDBC connection as necessary and returns it.ConnectionFactorygetConnectionFactory()Returns the connection factory to be used for creating connections.StringgetDelimiter()Get the delimiter character.StringgetDriverName()Retrieves the class name of the JDBC driver to use.PasswordgetEncryptedPassword()List<String>getHostNames()Get the list of configured database host names.DatabaseMetaDatagetMetadata()Gets the database metadata associated with this connection.StringgetPassword()Retrieves the password for connecting to the database.ResultSetMetaDatagetTableMetadata()Gets the metadata associated with this connection's table.ResultSetMetaDatagetTableMetadata(String statement)Gets the metadata associated with the provided statementStringgetTableName()Retrieves the name of the database table to access.StringgetUrl()Retrieves the URL for connecting to the database.StringgetUser()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.voidsetUrl(String url)Sets the URL for connecting to the database, for example:jdbc:odbc:SampleTest.voidsetUser(String user)Sets the user name for connecting to the database.booleantableExists()Determine if the table associated with the connection exists 
 - 
 
- 
- 
Method Detail
- 
setDriverName
public void setDriverName(String driverName)
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
public String 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
public void setUser(String user)
Sets the user name for connecting to the database.- Parameters:
 user- the user name for connecting to the database
 
- 
getUser
public String getUser()
Retrieves the user name for connecting to the database.- Specified by:
 getUserin interfaceConnectionSettings- Returns:
 - the user name for connecting to the database
 
 
- 
setPassword
public void setPassword(String password)
Sets the password for connecting to the database.- Parameters:
 password- the password for connecting to the database
 
- 
setEncryyptedPassword
public void setEncryyptedPassword(Password password)
 
- 
getPassword
public String getPassword()
Retrieves the password for connecting to the database.- Specified by:
 getPasswordin interfaceConnectionSettings- Returns:
 - the password for connecting to the database
 
 
- 
getEncryptedPassword
public Password getEncryptedPassword()
 
- 
setUrl
public void setUrl(String url)
Sets the URL for connecting to the database, for example:jdbc:odbc:SampleTest.- Parameters:
 url- the URL for connecting to the database
 
- 
getUrl
public String getUrl()
Retrieves the URL for connecting to the database.- Specified by:
 getUrlin interfaceConnectionSettings- Returns:
 - the URL for connecting to the database
 
 
- 
getTableName
public String getTableName()
Retrieves the name of the database table to access.- Returns:
 - the name of the database table to access
 
 
- 
setTableName
public void setTableName(String tableName)
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
public List<String> getHostNames()
Get the list of configured database host names.- Returns:
 - database host names
 
 
- 
setHostNames
public void setHostNames(List<String> hostNames)
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
public void setHostNames(String... hostNames)
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
public void setConnectionFactory(ConnectionFactory connectionFactory)
Sets the connection factory to be used for creating connections. Defaults toDefaultConnectionFactory.- Parameters:
 connectionFactory- the connection factory to be used for creating connections.
 
- 
getConnectionFactory
public ConnectionFactory getConnectionFactory()
Returns the connection factory to be used for creating connections. Defaults toDefaultConnectionFactory.- Returns:
 - the connection factory to be used for creating connections.
 
 
- 
getDelimiter
public String getDelimiter()
Get the delimiter character.- Returns:
 - delimiter character
 
 
- 
setDelimiter
public void setDelimiter(String delimiter)
Set the delimiter character used to delimiter table names in SQL queries.- Parameters:
 delimiter- delimiter character used to surround table names
 
- 
getConnection
public Connection 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:
 getConnection()
 
- 
getMetadata
public DatabaseMetaData getMetadata()
Gets the database metadata associated with this connection.- Returns:
 - a DatabaseMetaData object associated with this connection
 
 
- 
getTableMetadata
public ResultSetMetaData getTableMetadata()
Gets the metadata associated with this connection's table.- Returns:
 - a ResultSetMetaData object associated with this connection's table
 
 
- 
getTableMetadata
public ResultSetMetaData getTableMetadata(String statement)
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
public void executeAndLogStatement(String statement)
Executes the given statement closing the result set when finished.- Parameters:
 statement- the statement to execute
 
- 
executeAndLogSql
public ResultSet executeAndLogSql(String statement, boolean haltOnError, int fetchSize)
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
public void closeStatement(String statement, PreparedStatement s)
Closes a prepared statement object.- Parameters:
 statement- the original SQL statements- the prepared statement to close
 
 - 
 
 -