Top Description Fields Constructors Methods
org.hsqldb.util

public Class RCData

extends Object
Class Inheritance
Imports
java.io.BufferedReader, .File, .FileReader, .IOException, java.net.MalformedURLException, java.sql.Connection, .DriverManager, .SQLException, java.util.Properties, .Set, .HashSet, .StringTokenizer, java.util.regex.Pattern

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
The RC File section of the HyperSQL Utilities Guide, org.hsqldb.sample.SqlFileEmbedder

Field Summary

Modifier and TypeField and Description
public String
public static final String
private String
public String
public String
public String
public String
public String
public String
public String
public String

Constructor Summary

AccessConstructor and Description
public
RCData(File
File containing the authentication information.
file
,
String
Key to look up in the file. If null, then will echo all urlids in the file to stdout. (A rather ill-conceived design).
dbKey
)

Creates a RCDataObject by looking up the given key in the given authentication file.

public
RCData(String id, String url, String username, String password, String driver, String charset, String truststore)

Convenience constructor for backward compatibility.

public
RCData(String id, String url, String username, String password, String driver, String charset, String truststore, String libpath)

Wrapper for unset Transaction Isolation.

public
RCData(String
The identifier for these connection settings
id
,
String
The URL of the database to connect to
url
,
String
The username to log in as
username
,
String
The password of the username
password
,
String
The JDBC driver to use
driver
,
String
The character set to use
charset
,
String
The trust store to use
truststore
,
String
The JDBC library to add to CLASSPATH
libpath
,
String
The transaction level
ti
)

Creates a new RCData object.

Method Summary

Modifier and TypeMethod and Description
private static String
public static String

Returns:

formatted string
expandSysPropVars
(String
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.

public Connection

Returns:

New JDBC Connection
getConnection
()

Gets a JDBC Connection using the data of this RCData object.

public Connection

Returns:

New JDBC Connection
getConnection
(String
driver
curDriverIn
,
String
trusted store
curTrustStoreIn
)

Gets a JDBC Connection using the data of this RCData object with specified override elements

public String
public void
setDefaultJdbcDriver(String defaultJdbcDriverName)

public static void
setTI(Connection c, String tiString)

Set Transaction Isolation level on the specified JDBC Connection

public static String

Returns:

The string representation
tiToString
(int
Transaction levle
ti
)

Return a String representation for the given numerical java.sql.Connection Transaction level.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

charsetback to summary
public String charset
DEFAULT_JDBC_DRIVERback to summary
public static final String DEFAULT_JDBC_DRIVER
defaultJdbcDriverNameback to summary
private String defaultJdbcDriverName
driverback to summary
public String driver
idback to summary
public String id
libpathback to summary
public String libpath
passwordback to summary
public String password
tiback to summary
public String ti
truststoreback to summary
public String truststore
urlback to summary
public String url
usernameback to summary
public String username

Constructor Detail

RCDataback to summary
public RCData(File file, String dbKey) throws Exception

Creates a RCDataObject by looking up the given key in the given authentication file.

Parameters
file:File

File containing the authentication information.

dbKey:String

Key to look up in the file. If null, then will echo all urlids in the file to stdout. (A rather ill-conceived design).

Exceptions
Exception:
any exception
RCDataback to summary
public RCData(String id, String url, String username, String password, String driver, String charset, String truststore) throws Exception

Convenience constructor for backward compatibility.

See Also
RCData(String, String, String, String, String, String, String, String)
RCDataback to summary
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.

RCDataback to summary
public RCData(String id, String url, String username, String password, String driver, String charset, String truststore, String libpath, String ti) throws Exception

Creates a new RCData object.

The parameters driver, charset, truststore, and libpath are optional. Setting these parameters to NULL will set them to their default values.

Parameters
id:String

The identifier for these connection settings

url:String

The URL of the database to connect to

username:String

The username to log in as

password:String

The password of the username

driver:String

The JDBC driver to use

charset:String

The character set to use

truststore:String

The trust store to use

libpath:String

The JDBC library to add to CLASSPATH

ti:String

The transaction level

Exceptions
Exception:
if a non-optional parameter is set to NULL

Method Detail

angleBracketNullback to summary
private static String angleBracketNull(final String s)
expandSysPropVarsback to summary
public static 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.

Parameters
inString:String

String

Returns:String

formatted string

getConnectionback to summary
public Connection getConnection() throws SQLException, MalformedURLException

Gets a JDBC Connection using the data of this RCData object.

Returns:Connection

New JDBC Connection

Exceptions
SQLException:
on database access error
MalformedURLException:
on malformed URL
getConnectionback to summary
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:String

driver

curTrustStoreIn:String

trusted store

Returns:Connection

New JDBC Connection

Exceptions
MalformedURLException:
on malformed URL
SQLException:
on database access error
getDefaultJdbcDriverNameback to summary
public String getDefaultJdbcDriverName()
setDefaultJdbcDriverback to summary
public void setDefaultJdbcDriver(String defaultJdbcDriverName)
setTIback to summary
public static void setTI(Connection c, String tiString) throws SQLException

Set Transaction Isolation level on the specified JDBC Connection

tiToStringback to summary
public static String tiToString(int ti)

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:int

Transaction levle

Returns:String

The string representation

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.