Class ConnectionFactory


  • public final class ConnectionFactory
    extends java.lang.Object
    A factory for new database connections. Supported are regular JDBC drivers, as well as JNDI resources. FIXME: the registry currently is ClassLoader wide. I.e., if you start two repositories then you share the registered datasources...
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      java.lang.String getDataBaseType​(java.lang.String logicalName)  
      javax.sql.DataSource getDataSource​(java.lang.String logicalName)
      Retrieves a configured data source by logical name.
      javax.sql.DataSource getDataSource​(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password)
      Retrieve a DataSource for the specified properties.
      void registerDataSources​(DataSourceConfig dsc)
      Registers a number of data sources.
      static java.sql.Connection unwrap​(java.sql.Connection con)
      Needed for pre-10R2 Oracle blob support....:( This method actually assumes that we are using commons DBCP 1.2.2.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConnectionFactory

        public ConnectionFactory()
    • Method Detail

      • getDataSource

        public javax.sql.DataSource getDataSource​(java.lang.String logicalName)
                                           throws RepositoryException
        Retrieves a configured data source by logical name.
        Parameters:
        logicalName - the name of the DataSource
        Returns:
        a DataSource
        Throws:
        RepositoryException - if there is no DataSource with the given name
      • getDataBaseType

        public java.lang.String getDataBaseType​(java.lang.String logicalName)
                                         throws RepositoryException
        Parameters:
        logicalName - the name of the DataSource
        Returns:
        the configured database type
        Throws:
        RepositoryException - if there is no DataSource with the given name
      • getDataSource

        public javax.sql.DataSource getDataSource​(java.lang.String driver,
                                                  java.lang.String url,
                                                  java.lang.String user,
                                                  java.lang.String password)
                                           throws RepositoryException,
                                                  java.sql.SQLException
        Retrieve a DataSource for the specified properties. This can be a JNDI Data Source as well. To do that, the driver class name must reference a javax.naming.Context class (for example javax.naming.InitialContext), and the URL must be the JNDI URL (for example java:comp/env/jdbc/Test).
        Parameters:
        driver - the JDBC driver or the Context class
        url - the database URL
        user - the user name
        password - the password
        Returns:
        the DataSource
        Throws:
        RepositoryException - if the driver could not be loaded
        java.sql.SQLException - if the connection could not be established
      • close

        public void close()
      • unwrap

        public static java.sql.Connection unwrap​(java.sql.Connection con)
                                          throws java.sql.SQLException
        Needed for pre-10R2 Oracle blob support....:( This method actually assumes that we are using commons DBCP 1.2.2.
        Parameters:
        con - the commons-DBCP DelegatingConnection to unwrap
        Returns:
        the unwrapped connection
        Throws:
        java.sql.SQLException