Class DatabaseNamedConnectionPool

All Implemented Interfaces:
JMapServerSessionListener, KSchedulerClient

public class DatabaseNamedConnectionPool extends DatabaseConnectionPool implements JMapServerSessionListener
  • Constructor Details

  • Method Details

    • init

      public boolean init(DatabaseConnectionPoolInfo poolInfo, DatabaseConfig databaseConfig)
      Initializes the connection pool with the specified pool info.
      Overrides:
      init in class DatabaseConnectionPool
      Parameters:
      poolInfo - the DatabaseConnectionPoolInfo instance associated with this DatabaseconnectionPool
      databaseConfig - the database configuration to use with borrowed connections.
      Returns:
      true if no error occurred during the initialization.
    • initialize

      public void initialize(int minimumSize, long shrinkTime, long cleanupPeriod, long recyclePeriod) throws Exception
      Description copied from class: KObjectPool
      Initializes a KObjectPool instance with the specified minimum size, recycle period, clean up period and shrink period
      Overrides:
      initialize in class KObjectPool
      Parameters:
      minimumSize - the minimum number of objects in this pool
      shrinkTime - the amount of time extra objects can remain inactive before it eligible for cleanup
      cleanupPeriod - the amount of time between cleanups
      recyclePeriod - the amount of time an initial object can remain inactive before it is recycled (closed than reopen).
      Throws:
      Exception - if an error occurred while initializing the object pool
    • schCallback

      public void schCallback(int jobId)
      This method is automatically called by the KScheduler to either perform the clean up or object recycle jobs
      Specified by:
      schCallback in interface KSchedulerClient
      Overrides:
      schCallback in class KObjectPool
      Parameters:
      jobId - the job Id to determine which job will be done
    • borrowConnection

      public Connection borrowConnection() throws SQLException
      Borrows a connection from the main connection pool.
      Overrides:
      borrowConnection in class DatabaseConnectionPool
      Returns:
      a connection from the main connection pool.
      Throws:
      SQLException
    • borrowConnection

      public Connection borrowConnection(int id) throws SQLException
      Borrows a connection from the pool for exclusive use until it is returned by calling the method returnConnection.
      Overrides:
      borrowConnection in class DatabaseConnectionPool
      Parameters:
      id - an object which identifies the connection borrower.
      Returns:
      a database connection
      Throws:
      SQLException
    • returnConnection

      public void returnConnection(Connection conn)
      Returns the specified connection to the main connection pool.
      Overrides:
      returnConnection in class DatabaseConnectionPool
      Parameters:
      conn - the connection to return.
    • returnConnection

      public void returnConnection(int id, Connection conn)
      Returns a connection to the poll that was obtained using the method borrowConnection. This method MUST ABSOLUTELY be called when the connection not needed anymore otherwise it will stay unavailable for ever for other users.
      Overrides:
      returnConnection in class DatabaseConnectionPool
      Parameters:
      id - an integer which identifies the connection borrower.
      conn - the corresponding connection
    • expire

      public void expire(Object o)
      Should not be called.
      Overrides:
      expire in class DatabaseConnectionPool
      Parameters:
      o - object (DatabaseConnectionPool) to close
    • sessionCreated

      public void sessionCreated(JMapServerSessionEvent event)
      Specified by:
      sessionCreated in interface JMapServerSessionListener
    • sessionDestroyed

      public void sessionDestroyed(JMapServerSessionEvent event)
      Specified by:
      sessionDestroyed in interface JMapServerSessionListener
    • getMonitoringInfo

      public PoolMonitoringInfo getMonitoringInfo()
      This method gets the PoolMonitorInfo associated with the KObject pool instance. The PoolMonitorInfo maintains the pool statistics
      Overrides:
      getMonitoringInfo in class KObjectPool
      Returns:
      the corresponding PoolMonitorInfo instance
      See Also:
    • close

      public void close()
      Description copied from class: KObjectPool
      This method closes one by one all the objects currently opened for this the pool
      Overrides:
      close in class KObjectPool