Interface IConnectionProvider

  • All Known Implementing Classes:
    DatabaseSupport, DerbyConnectionProvider, DerbyFhirDatabase, JdbcConnectionProvider, PoolConnectionProvider

    public interface IConnectionProvider
    Provides an abstract way to obtain a JDBC connection. Hides the implementation, making it easier to switch between in-memory instances of Derby used for unit-tests and connections to actual database instances either in pure Java or JEE environments like Liberty Profile. One IConnectionProvider instance is used per data source. If you need to connect to more than one database, you'll need multiple providers. This is just simple wrapper stuff...allowing us to switch out underlying pool implementations should we want/need to. No support for distributed transactions or anything fancy like that.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void commitTransaction()
      Commit the current transaction if there's an actual connection associated with this thread (i.e.
      void describe​(java.lang.String prefix, java.lang.StringBuilder cfg, java.lang.String key)
      Describe self, for writing configuration information to log file for test record purposes
      java.sql.Connection getConnection()
      Obtain a new connection to a data-source which this provider has been configured for.
      default int getPoolSize()
      used to control threading size.
      IDatabaseTranslator getTranslator()
      Get the translator associated with this connection provider.
      void rollbackTransaction()
      Roll back the transaction for the connection associated with this thread, if one exists
    • Method Detail

      • getConnection

        java.sql.Connection getConnection()
                                   throws java.sql.SQLException
        Obtain a new connection to a data-source which this provider has been configured for.
        Returns:
        Throws:
        java.sql.SQLException
      • getTranslator

        IDatabaseTranslator getTranslator()
        Get the translator associated with this connection provider. Supports interpretation of SQLExceptions and the ability to tweak SQL statements to handle differences between databases
        Returns:
      • commitTransaction

        void commitTransaction()
                        throws java.sql.SQLException
        Commit the current transaction if there's an actual connection associated with this thread (i.e. if getConnection() has been called at least once), otherwise do nothing.
        Throws:
        java.sql.SQLException
      • rollbackTransaction

        void rollbackTransaction()
                          throws java.sql.SQLException
        Roll back the transaction for the connection associated with this thread, if one exists
        Throws:
        java.sql.SQLException
      • describe

        void describe​(java.lang.String prefix,
                      java.lang.StringBuilder cfg,
                      java.lang.String key)
        Describe self, for writing configuration information to log file for test record purposes
        Parameters:
        cfg -
        key -
      • getPoolSize

        default int getPoolSize()
        used to control threading size.