Module org.hsqldb

Class RCData

java.lang.Object
org.hsqldb.util.RCData

public class RCData extends Object
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 Details

  • Constructor Details

    • RCData

      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 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 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 - The identifier for these connection settings
      url - The URL of the database to connect to
      username - The username to log in as
      password - The password of the username
      driver - The JDBC driver to use
      charset - The character set to use
      truststore - The trust store to use
      libpath - The JDBC library to add to CLASSPATH
      ti - The transaction level
      Throws:
      Exception - if the a non-optional parameter is set to NULL
  • Method Details

    • setDefaultJdbcDriver

      public void setDefaultJdbcDriver(String defaultJdbcDriverName)
    • getDefaultJdbcDriverName

      public String getDefaultJdbcDriverName()
    • toString

      public String 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); }
      Overrides:
      toString in class Object
      Returns:
      string representation
    • getConnection

      public Connection getConnection() throws SQLException, MalformedURLException
      Gets a JDBC Connection using the data of this RCData object.
      Returns:
      New JDBC Connection
      Throws:
      SQLException - on database access error
      MalformedURLException - 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 - driver
      curTrustStoreIn - trusted store
      Returns:
      New JDBC Connection
      Throws:
      MalformedURLException - on malformed URL
      SQLException - on database access error
    • expandSysPropVars

      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
      Returns:
      formatted string
    • setTI

      public static void setTI(Connection c, String tiString) throws SQLException
      Set Transaction Isolation level on the specified JDBC Connection
      Throws:
      SQLException
    • tiToString

      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 to much.

      Parameters:
      ti - Transaction levle
      Returns:
      The string representation