Class RCData
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 newRCDataobject. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringexpandSysPropVars(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 elementsvoidsetDefaultJdbcDriver(String defaultJdbcDriverName) static voidsetTI(Connection c, String tiString) Set Transaction Isolation level on the specified JDBC Connectionstatic StringtiToString(int ti) Return a String representation for the given numerical java.sql.Connection Transaction level.toString()
-
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
-
RCData
-
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 newRCDataobject.The parameters driver, charset, truststore, and libpath are optional. Setting these parameters to
NULLwill 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 a non-optional parameter is set toNULL
-
-
Method Details
-
setDefaultJdbcDriver
-
getDefaultJdbcDriverName
-
toString
-
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
-
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 too much.
- Parameters:
ti- Transaction levle- Returns:
- The string representation
-