Class ConnectionSet

java.lang.Object
ru.bgcrm.util.sql.ConnectionSet
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
SingleConnectionSet

public class ConnectionSet extends Object implements AutoCloseable
Set with DB connections, taken from a pool on demand.
  • Field Details

  • Constructor Details

    • ConnectionSet

      public ConnectionSet(ConnectionPool setup, boolean autoCommit)
    • ConnectionSet

      protected ConnectionSet(Connection master)
  • Method Details

    • getConnection

      public Connection getConnection()
      Provides master DB connection to the main database.
      Returns:
    • getSlaveConnection

      public Connection getSlaveConnection()
      Gets slave connection to read-only DB replica.
      Returns:
    • getTrashConnection

      public Connection getTrashConnection(String tableName, int defaultType)
      Gets connection to so-called 'trash' DB, containing non-critical data.
      Parameters:
      tableName - table name.
      defaultType - DB type returned if no trash DB is configured, can be:
       TYPE_SLAVE - slave DB connection;
       TYPE_FAKE -  instance of FakeConnection, does not do anything;
       TYPE_MASTER - master DB connection.
       
      Returns:
    • commit

      public void commit() throws SQLException
      Commits all the connections
      Throws:
      SQLException
    • rollback

      public void rollback()
      Rolls back all the connections
    • close

      public void close()
      Closes all the connections
      Specified by:
      close in interface AutoCloseable
    • recycle

      @Deprecated public void recycle()
      Deprecated.