public class JDBCConnector extends Object implements ConnectionSettings
Constructor and Description |
---|
JDBCConnector() |
Modifier and Type | Method and Description |
---|---|
void |
cleanupConnection()
Close all resources opened during getConnection()
|
void |
closeResultSetAndStatement(String statement,
ResultSet rs)
Closes a result set object.
|
void |
closeStatement(String statement,
PreparedStatement s)
Closes a prepared statement object.
|
ResultSet |
executeAndLogSql(String statement,
boolean haltOnError,
int fetchSize)
Executes a given SQL statement, returning the result.
|
void |
executeAndLogStatement(String statement)
Executes the given statement closing the result set when finished.
|
Connection |
getConnection()
Creates a JDBC connection as necessary and returns it.
|
ConnectionFactory |
getConnectionFactory()
Returns the connection factory to be used for creating connections.
|
String |
getDelimiter()
Get the delimiter character.
|
String |
getDriverName()
Retrieves the class name of the JDBC driver to use.
|
Password |
getEncryptedPassword() |
List<String> |
getHostNames()
Get the list of configured database host names.
|
DatabaseMetaData |
getMetadata()
Gets the database metadata associated with this connection.
|
String |
getPassword()
Retrieves the password for connecting to the database.
|
ResultSetMetaData |
getTableMetadata()
Gets the metadata associated with this connection's table.
|
ResultSetMetaData |
getTableMetadata(String statement)
Gets the metadata associated with the provided statement
|
String |
getTableName()
Retrieves the name of the database table to access.
|
String |
getUrl()
Retrieves the URL for connecting to the database.
|
String |
getUser()
Retrieves the user name for connecting to the database.
|
void |
setConnectionFactory(ConnectionFactory connectionFactory)
Sets the connection factory to be used for creating connections.
|
void |
setDelimiter(String delimiter)
Set the delimiter character used to delimiter table names in SQL queries.
|
void |
setDriverName(String driverName)
Sets the class name of the JDBC driver to use, for example:
"sun.jdbc.odbc.JdbcOdbcDriver" . |
void |
setEncryyptedPassword(Password password) |
void |
setHostNames(List<String> hostNames)
Set the list of database host names that can be used to execute queries.
|
void |
setHostNames(String... hostNames)
Set the list of database host names that can be used to execute queries.
|
void |
setPassword(String password)
Sets the password for connecting to the database.
|
void |
setTableName(String tableName)
Sets the name of the database table to access.
|
void |
setUrl(String url)
Sets the URL for connecting to the database, for example:
jdbc:odbc:SampleTest . |
void |
setUser(String user)
Sets the user name for connecting to the database.
|
boolean |
tableExists()
Determine if the table associated with the connection exists
|
public void setDriverName(String driverName)
"sun.jdbc.odbc.JdbcOdbcDriver"
.driverName
- the class name of the JDBC driver to usepublic String getDriverName()
getDriverName
in interface ConnectionSettings
public void setUser(String user)
user
- the user name for connecting to the databasepublic String getUser()
getUser
in interface ConnectionSettings
public void setPassword(String password)
password
- the password for connecting to the databasepublic void setEncryyptedPassword(Password password)
public String getPassword()
getPassword
in interface ConnectionSettings
public Password getEncryptedPassword()
public void setUrl(String url)
jdbc:odbc:SampleTest
.url
- the URL for connecting to the databasepublic String getUrl()
getUrl
in interface ConnectionSettings
public String getTableName()
public void setTableName(String tableName)
WriteToJDBC
, but optional for ReadFromJDBC
,
since ReadFromJDBC#setSelectStatement(String)
may be used instead.tableName
- the name of the database table to accesspublic List<String> getHostNames()
public void setHostNames(List<String> hostNames)
hostNames
- list of database host namespublic void setHostNames(String... hostNames)
hostNames
- list of database host namespublic void setConnectionFactory(ConnectionFactory connectionFactory)
DefaultConnectionFactory
.connectionFactory
- the connection factory to be used for creating connections.public ConnectionFactory getConnectionFactory()
DefaultConnectionFactory
.public String getDelimiter()
public void setDelimiter(String delimiter)
delimiter
- delimiter character used to surround table namespublic Connection getConnection()
getConnectionFactory()
method.public void cleanupConnection()
getConnection()
public DatabaseMetaData getMetadata()
public ResultSetMetaData getTableMetadata()
public ResultSetMetaData getTableMetadata(String statement)
public boolean tableExists()
public void executeAndLogStatement(String statement)
statement
- the statement to executepublic ResultSet executeAndLogSql(String statement, boolean haltOnError, int fetchSize)
statement
- the statement to executehaltOnError
- if true an error will be thrown if a SQLException is encounteredfetchSize
- the fetch size to use with the PreparedStatement
public void closeStatement(String statement, PreparedStatement s)
statement
- the original SQL statements
- the prepared statement to closeCopyright © 2021 Actian Corporation. All rights reserved.