Class ConnectionSet

java.lang.Object
ru.bgcrm.util.sql.ConnectionSet
Direct Known Subclasses:
SingleConnectionSet

public class ConnectionSet extends Object
Set with DB connections, taken from pools on demand.
  • Field Details

  • Constructor Details

    • ConnectionSet

      protected ConnectionSet(Connection master)
    • ConnectionSet

      protected ConnectionSet(Connection master, boolean autoCommit)
    • ConnectionSet

      public ConnectionSet(ConnectionPool setup, boolean autoCommit)
  • Method Details

    • getConnection

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

      protected Connection newMasterConnection()
    • newSlaveConnection

      protected Connection newSlaveConnection()
    • newTrashConnection

      protected Connection newTrashConnection(String tableName)
    • 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 Exception
      Throws:
      Exception
    • recycle

      public void recycle()
    • getAutoCommit

      public boolean getAutoCommit()
    • setAutoCommit

      public void setAutoCommit(boolean autoCommit)
      Sets autocommit property to all connections.
      Parameters:
      autoCommit - wanted value.
    • rollback

      public void rollback()