Class ConnectionPool

java.lang.Object
org.bgerp.util.sql.pool.ConnectionPool

public class ConnectionPool extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • getDataSource

      public DataSource getDataSource()
    • getConnectionSet

      public ConnectionSet getConnectionSet()
    • getConnectionSet

      public ConnectionSet getConnectionSet(boolean autoCommit)
    • close

      public void close()
    • getDBConnectionFromPool

      public final Connection getDBConnectionFromPool()
      Returns a connection to the Master DB from the pool
      Returns:
      the connection to the Master DB, or null if unavailable
    • getSlaveDataSource

      public final DataSource getSlaveDataSource()
    • getDBSlaveConnectionFromPool

      public final Connection getDBSlaveConnectionFromPool()
      Returns a connection to the Slave DB from the pool. If Slave DB isn't defined in the configuration - returns from the Master pool.
      Returns:
      the connection
    • getDBSlaveConnectionFromPool

      public final Connection getDBSlaveConnectionFromPool(Connection master)
      Returns a connection to the Slave DB from the pool. If Slave DB isn't defined in the configuration - returns from the Master pool.
      Parameters:
      master - if false, returns null when there are no slave bases
      Returns:
      the connection
    • getDBTrashConnectionFromPool

      public final Connection getDBTrashConnectionFromPool(String tableName, int retType)
      Returns a connection to the trash DB if it's configured for the table, or depending on retType
      Parameters:
      tableName - table name
      retType - RETURN_FAKE, RETURN_SLAVE or RETURN_MASTER
      Returns:
      if trash DB configuration is not specified, a connection to the master DB, a fake connection, or a connection to the Slave DB may be returned
    • getDBTrashOrMasterConnectionFromPool

      public final Connection getDBTrashOrMasterConnectionFromPool(String tableName)
      Returns a connection to the dedicated "trash" or Master database (if the trash database is not found)
      Parameters:
      tableName -
      Returns:
      the connection
    • getDBTrashOrSlaveConnectionFromPool

      public final Connection getDBTrashOrSlaveConnectionFromPool(String tableName)
      Returns a connection to the dedicated "trash" or Slave database
      Parameters:
      tableName -
      Returns:
      the connection
    • getSlaveBaseId

      public final Set<String> getSlaveBaseId()
      Returns identifiers of slave databases
      Returns:
      the slave database identifiers
    • getTrashBaseId

      public final Set<String> getTrashBaseId()
      Returns identifiers of trash databases
      Returns:
      the trash database identifiers
    • getTrashConnectionFromPool

      public final Connection getTrashConnectionFromPool(String poolId)
      Returns a connection to the trash database. If the database ID is incorrect, returns null with all the consequences, since this is used only for forced database selection in some specific service cases.
      Parameters:
      poolId - - database ID
      Returns:
      connection
    • poolStatus

      public String poolStatus()
      Returns:
      status text report for connection pools
    • getDbTrace

      public String getDbTrace()
      Returns:
      pool connections borrowing stack traces text report
    • setReplicationNotBehindMaster

      @Deprecated public void setReplicationNotBehindMaster(String slaveId, boolean isNotBehind)
      Deprecated.
      Enables/disables the Slave database lag flag
      Parameters:
      slaveId - Slave database identifier
      isNotBehind - true - lag disabled, false - lag enabled
    • isReplicationNotBehindMaster

      @Deprecated public boolean isReplicationNotBehindMaster(String slaveId)
      Deprecated.
      Checks whether the Slave database is lagging
      Parameters:
      slaveId - Slave database identifier
      Returns:
      true if not lagging
    • isReplicationAvailable

      @Deprecated public boolean isReplicationAvailable(String slaveId)
      Deprecated.
      Checks availability of the Slave database
      Parameters:
      slaveId - Slave database identifier
      Returns:
      true if available, false if not available