Module org.hsqldb

Class RCData


  • public class RCData
    extends java.lang.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, org.hsqldb.sample.SqlFileEmbedder
    • Constructor Summary

      Constructors 
      Constructor Description
      RCData​(java.io.File file, java.lang.String dbKey)
      Creates a RCDataObject by looking up the given key in the given authentication file.
      RCData​(java.lang.String id, java.lang.String url, java.lang.String username, java.lang.String password, java.lang.String driver, java.lang.String charset, java.lang.String truststore)
      Convenience constructor for backward compatibility.
      RCData​(java.lang.String id, java.lang.String url, java.lang.String username, java.lang.String password, java.lang.String driver, java.lang.String charset, java.lang.String truststore, java.lang.String libpath)
      Wrapper for unset Transaction Isolation.
      RCData​(java.lang.String id, java.lang.String url, java.lang.String username, java.lang.String password, java.lang.String driver, java.lang.String charset, java.lang.String truststore, java.lang.String libpath, java.lang.String ti)
      Creates a new RCData object.
    • Method Summary

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

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DEFAULT_JDBC_DRIVER

        public static final java.lang.String DEFAULT_JDBC_DRIVER
        See Also:
        Constant Field Values
      • id

        public java.lang.String id
      • url

        public java.lang.String url
      • username

        public java.lang.String username
      • password

        public java.lang.String password
      • ti

        public java.lang.String ti
      • driver

        public java.lang.String driver
      • charset

        public java.lang.String charset
      • truststore

        public java.lang.String truststore
      • libpath

        public java.lang.String libpath
    • Constructor Detail

      • RCData

        public RCData​(java.io.File file,
                      java.lang.String dbKey)
               throws java.lang.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:
        java.lang.Exception - any exception
      • RCData

        public RCData​(java.lang.String id,
                      java.lang.String url,
                      java.lang.String username,
                      java.lang.String password,
                      java.lang.String driver,
                      java.lang.String charset,
                      java.lang.String truststore)
               throws java.lang.Exception
        Convenience constructor for backward compatibility.
        Throws:
        java.lang.Exception
        See Also:
        RCData(String,String,String,String,String,String,String,String)
      • RCData

        public RCData​(java.lang.String id,
                      java.lang.String url,
                      java.lang.String username,
                      java.lang.String password,
                      java.lang.String driver,
                      java.lang.String charset,
                      java.lang.String truststore,
                      java.lang.String libpath)
               throws java.lang.Exception
        Wrapper for unset Transaction Isolation.
        Throws:
        java.lang.Exception
      • RCData

        public RCData​(java.lang.String id,
                      java.lang.String url,
                      java.lang.String username,
                      java.lang.String password,
                      java.lang.String driver,
                      java.lang.String charset,
                      java.lang.String truststore,
                      java.lang.String libpath,
                      java.lang.String ti)
               throws java.lang.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:
        java.lang.Exception - if a non-optional parameter is set to NULL
    • Method Detail

      • setDefaultJdbcDriver

        public void setDefaultJdbcDriver​(java.lang.String defaultJdbcDriverName)
      • getDefaultJdbcDriverName

        public java.lang.String getDefaultJdbcDriverName()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getConnection

        public java.sql.Connection getConnection()
                                          throws java.sql.SQLException,
                                                 java.net.MalformedURLException
        Gets a JDBC Connection using the data of this RCData object.
        Returns:
        New JDBC Connection
        Throws:
        java.sql.SQLException - on database access error
        java.net.MalformedURLException - on malformed URL
      • getConnection

        public java.sql.Connection getConnection​(java.lang.String curDriverIn,
                                                 java.lang.String curTrustStoreIn)
                                          throws java.net.MalformedURLException,
                                                 java.sql.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:
        java.net.MalformedURLException - on malformed URL
        java.sql.SQLException - on database access error
      • expandSysPropVars

        public static java.lang.String expandSysPropVars​(java.lang.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​(java.sql.Connection c,
                                 java.lang.String tiString)
                          throws java.sql.SQLException
        Set Transaction Isolation level on the specified JDBC Connection
        Throws:
        java.sql.SQLException
      • tiToString

        public static java.lang.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 - Transaction levle
        Returns:
        The string representation