RCData (HSQLDB 2.4.0 API)
Date: 2017-04-09

org.hsqldb.lib

## Class RCData

- java.lang.Object
- - org.hsqldb.lib.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:
    The RC File section of the HyperSQL Utilities Guide, `SqlFileEmbedder`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `String` | `charset`
    `static String` | `DEFAULT_JDBC_DRIVER`
    `String` | `driver`
    `String` | `id`
    `String` | `libpath`
    `String` | `password`
    `String` | `ti`
    `String` | `truststore`
    `String` | `url`
    `String` | `username`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RCData(File file, String dbKey)` Creates 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 new `RCData` object.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `Connection` | `getConnection()` Gets a JDBC Connection using the data of this RCData object.
    `Connection` | `getConnection(String curDriverIn, String curTrustStoreIn)` Gets a JDBC Connection using the data of this RCData object with specified override elements
    `String` | `getDefaultJdbcDriverName()`
    `void` | `setDefaultJdbcDriver(String defaultJdbcDriverName)`
    `static void` | `setTI(Connection c, String tiString)` Set Transaction Isolation level on the specified JDBC Connection
    `static String` | `tiToString(int ti)` Return a String representation for the given numerical java.sql.Connection Transaction level.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_JDBC_DRIVER

          public static final String DEFAULT_JDBC_DRIVER

      See Also:
        Constant Field Values

    - #### id

          public String id

    - #### url

          public String url

    - #### username

          public String username

    - #### password

          public String password

    - #### ti

          public String ti

    - #### driver

          public String driver

    - #### charset

          public String charset

    - #### truststore

          public String truststore

    - #### libpath

          public String libpath

  - ### Constructor Detail

    - #### 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(String,String,String,String,String,String,String,String)`

    - #### 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 Detail

    - #### setDefaultJdbcDriver

          public void setDefaultJdbcDriver(String defaultJdbcDriverName)

    - #### getDefaultJdbcDriverName

          public String getDefaultJdbcDriverName()

    - #### getConnection

          public Connection getConnection()
                                   throws ClassNotFoundException,
                                          SQLException,
                                          MalformedURLException

      Gets a JDBC Connection using the data of this RCData object.
      Returns:
        New JDBC Connection
      Throws:
        `ClassNotFoundException` - on class not found
        `SQLException` - on database access error
        `MalformedURLException` - on malformed URL

    - #### getConnection

          public Connection getConnection(String curDriverIn,
                                          String curTrustStoreIn)
                                   throws ClassNotFoundException,
                                          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:
        `ClassNotFoundException` - on class not found
        `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.

    - #### 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

Copyright © 2001 - 2017 HSQL Development Group.