Class PoolManager


  • public final class PoolManager
    extends java.lang.Object
    This class can manages a set of database connections pools. It's implemented as a singleton. It provides methods to get or release a connection from a given pool.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void freeConnection​(java.lang.String strPoolName, java.sql.Connection con)
      Returns a connection to pool.
      java.sql.Connection getConnection​(java.lang.String strPoolName)
      Returns an available connection from the pool.
      javax.sql.DataSource getDataSource​(java.lang.String strPoolName)
      Returns the datasource for a given pool name
      static PoolManager getInstance​(java.io.InputStream isDbProperties)
      This method returns the unique instance of the PoolManager.
      java.util.Collection<ConnectionService> getPools()
      Returns all pools available
      ReferenceList getPoolsInfos()
      Returns pool's infos (currently opened connections)
      void release()
      Releases all connections from all the pool.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static PoolManager getInstance​(java.io.InputStream isDbProperties)
                                       throws LuteceInitException
        This method returns the unique instance of the PoolManager.
        Parameters:
        isDbProperties - An InputStream on a db.properties File to initialiaze the pool if it's not already created.
        Returns:
        The unique instance of Poolmanager.
        Throws:
        LuteceInitException - If any error occured
      • getConnection

        public java.sql.Connection getConnection​(java.lang.String strPoolName)
        Returns an available connection from the pool.
        Parameters:
        strPoolName - The pool name
        Returns:
        A connection
      • freeConnection

        public void freeConnection​(java.lang.String strPoolName,
                                   java.sql.Connection con)
        Returns a connection to pool.
        Parameters:
        strPoolName - Pool's name
        con - A released connection
      • release

        public void release()
        Releases all connections from all the pool.
      • getPools

        public java.util.Collection<ConnectionService> getPools()
        Returns all pools available
        Returns:
        The list of available pools
      • getPoolsInfos

        public ReferenceList getPoolsInfos()
        Returns pool's infos (currently opened connections)
        Returns:
        The pool's infos
      • getDataSource

        public javax.sql.DataSource getDataSource​(java.lang.String strPoolName)
        Returns the datasource for a given pool name
        Parameters:
        strPoolName - The Pool name
        Returns:
        A data source object