Interface DatasourceManager


public interface DatasourceManager
  • Field Details

    • DATABASE_CONNECTION_RESOURCE

      static final ResourceType DATABASE_CONNECTION_RESOURCE
    • LOGGER_ROOT

      static final String LOGGER_ROOT
      Root of the logger tree this subsystem writes under. Child loggers append a suffix, for example .Selects for query logging and .ConnectionManager for pool management.

      Published here rather than kept on the implementation so anything querying these logs can derive the names instead of repeating them as literals.

      See Also:
  • Method Details

    • getConnection

      SRConnection getConnection(String dataSource) throws SQLException
      Retrieves a JDBC new connection for the given named datasource. If the datasource named is currently faulted, the connection may come from its failover datasource, if there is one.

      Throws:
      IllegalArgumentException - if the provided datasource does not exist.
      SQLException
    • validateJdbcDriverClassLoaded

      boolean validateJdbcDriverClassLoaded(String classname)
      Checks whether the given JDBC driver class is loaded.
    • createDataSource

      DataSource createDataSource(Properties props) throws Exception
      Throws:
      Exception
    • beginTransaction

      String beginTransaction(String datasource, int isolationLevel, long timeout) throws SQLException
      Begins a transaction against the named datasource.
      Parameters:
      datasource - The name of the datasource to use
      isolationLevel - a constant from java.sql.Connection indicating the new transaction's isolation level.
      timeout - Time to wait between uses of the transaction's connection before it will be automatically rolled back and closed.
      Returns:
      A new transaction ID, which will be used for all further interaction with this transaction.
      Throws:
      SQLException
    • beginTransaction

      void beginTransaction(String id, String datasource, int isolationLevel, long timeout) throws SQLException
      Named queries want to specify their own transaction ID. No return value needed, because we specified ID.
      Parameters:
      id - The transaction ID. Not empty.
      datasource - The name of the datasource to use.
      isolationLevel - a constant from java.sql.Connection indicating the new transaction's isolation level.
      timeout - Time to wait between uses of the transaction's connection before it will be automatically rolled back and closed.
      Throws:
      SQLException
    • commitTransaction

      void commitTransaction(String txId) throws SQLException
      Commits any pending statements for the given transaction.
      Throws:
      SQLException
    • rollbackTransaction

      void rollbackTransaction(String txId) throws SQLException
      Rolls back any statements executed on this transaction since the last commit or since the beginning of the transaction
      Throws:
      SQLException
    • closeTransaction

      void closeTransaction(String txId) throws SQLException
      Closes the given transaction. The transaction ID is no longer valid after this method completes.
      Throws:
      SQLException
    • touchTransaction

      void touchTransaction(String txId)
      Updates the last-used time for the transaction, if it still exists.
    • getTransactionConnection

      SRConnection getTransactionConnection(String txId) throws SQLException
      Returns the connection for a given transaction id.
      Throws:
      SQLException
    • getDatasource

      @Nullable Datasource getDatasource(String name)
      Looks up a datasource by name. Will return null if the datasource doesn't exist
    • getDatasources

      List<Datasource> getDatasources()
      Returns a list of all known datasources currently installed. This list is not backed by the manager - changes to it will not have any effect.
    • getMetaProvider

      DatasourceMetaProvider getMetaProvider()
    • addDatasourceListener

      void addDatasourceListener(DatasourceListener listener)
      Registers a new DatasourceListener to be notified of changes to datasource status or configuration. The listener will receive callbacks when a datasource's status changes or when there is a change to the datasource itself.
      Parameters:
      listener - the DatasourceListener to be added. Cannot be null.
    • removeDatasourceListener

      void removeDatasourceListener(DatasourceListener listener)
      Removes a previously added listener that is monitoring changes to datasources.
      Parameters:
      listener - the DatasourceListener to be removed. This listener will no longer receive updates regarding datasource status or configuration changes.