java.lang.Object
org.hsqldb.util.RCData
Manages all the details we need to connect up to JDBC database(s),
in a declarative way.
The file src/org/hsqldb/sample/SqlFileEmbedder.java
in the HSQLDB distribution provides an example of how to use RCData for your
own programs.
- Author:
- Blaine Simpson (blaine dot simpson at admc dot com)
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a RCDataObject by looking up the given key in the given authentication file.RCData
(String id, String url, String username, String password, String driver, String charset, String truststore) Convenience constructor for backward compatibility.RCData
(String id, String url, String username, String password, String driver, String charset, String truststore, String libpath) Wrapper for unset Transaction Isolation.RCData
(String id, String url, String username, String password, String driver, String charset, String truststore, String libpath, String ti) Creates a newRCData
object. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
expandSysPropVars
(String inString) Returns a copy of the given String with System property names in the format${system.property}
replaced by the corresponding Java System Properties.Gets a JDBC Connection using the data of this RCData object.getConnection
(String curDriverIn, String curTrustStoreIn) Gets a JDBC Connection using the data of this RCData object with specified override elementsvoid
setDefaultJdbcDriver
(String defaultJdbcDriverName) static void
setTI
(Connection c, String tiString) Set Transaction Isolation level on the specified JDBC Connectionstatic String
tiToString
(int ti) Return a String representation for the given numerical java.sql.Connection Transaction level.toString()
DISABLED DUE TO SECURITY CONCERNS.
-
Field Details
-
DEFAULT_JDBC_DRIVER
- See Also:
-
id
-
url
-
username
-
password
-
ti
-
driver
-
charset
-
truststore
-
libpath
-
-
Constructor Details
-
RCData
Creates a RCDataObject by looking up the given key in the given authentication file.- Parameters:
file
- File containing the authentication information.dbKey
- Key to look up in the file. If null, then will echo all urlids in the file to stdout. (A rather ill-conceived design).- Throws:
Exception
- any exception
-
RCData
public RCData(String id, String url, String username, String password, String driver, String charset, String truststore) throws Exception Convenience constructor for backward compatibility.- Throws:
Exception
- See Also:
-
RCData
public RCData(String id, String url, String username, String password, String driver, String charset, String truststore, String libpath) throws Exception Wrapper for unset Transaction Isolation.- Throws:
Exception
-
RCData
public RCData(String id, String url, String username, String password, String driver, String charset, String truststore, String libpath, String ti) throws Exception Creates a newRCData
object.The parameters driver, charset, truststore, and libpath are optional. Setting these parameters to
NULL
will set them to their default values.- Parameters:
id
- The identifier for these connection settingsurl
- The URL of the database to connect tousername
- The username to log in aspassword
- The password of the usernamedriver
- The JDBC driver to usecharset
- The character set to usetruststore
- The trust store to uselibpath
- The JDBC library to add to CLASSPATHti
- The transaction level- Throws:
Exception
- if the a non-optional parameter is set toNULL
-
-
Method Details
-
setDefaultJdbcDriver
-
getDefaultJdbcDriverName
-
toString
DISABLED DUE TO SECURITY CONCERNS. Just for testing and debugging. N.b. this echoes passwords! public void report() { System.err.println("urlid: " + id + ", url: " + url + ", username: " + username + ", password: " + password); } -
getConnection
Gets a JDBC Connection using the data of this RCData object.- Returns:
- New JDBC Connection
- Throws:
SQLException
- on database access errorMalformedURLException
- on malformed URL
-
getConnection
public Connection getConnection(String curDriverIn, String curTrustStoreIn) throws MalformedURLException, SQLException Gets a JDBC Connection using the data of this RCData object with specified override elements- Parameters:
curDriverIn
- drivercurTrustStoreIn
- trusted store- Returns:
- New JDBC Connection
- Throws:
MalformedURLException
- on malformed URLSQLException
- on database access error
-
expandSysPropVars
Returns a copy of the given String with System property names in the format${system.property}
replaced by the corresponding Java System Properties.- Parameters:
inString
- String- Returns:
- formatted string
-
setTI
Set Transaction Isolation level on the specified JDBC Connection- Throws:
SQLException
-
tiToString
Return a String representation for the given numerical java.sql.Connection Transaction level.Database implementations are free to provide their own transaction isolation levels, so you can't depend upon this method to much.
- Parameters:
ti
- Transaction levle- Returns:
- The string representation
-