Class ConnectionPool


  • public class ConnectionPool
    extends java.lang.Object
    The class that defines a connection pool.
    • Field Detail

      • dbURL

        protected final java.lang.String dbURL
      • userName

        protected final java.lang.String userName
      • password

        protected final java.lang.String password
      • freePointer

        protected volatile int freePointer
      • activeConnections

        protected volatile int activeConnections
      • closed

        protected volatile boolean closed
      • freeConnections

        protected final java.sql.Connection[] freeConnections
      • connectionCleanupTimeouts

        protected final long[] connectionCleanupTimeouts
      • expiration

        protected final long expiration
      • debug

        protected final boolean debug
      • outstandingConnections

        protected final java.util.Set<WrappedConnection> outstandingConnections
    • Constructor Detail

      • ConnectionPool

        public ConnectionPool​(java.lang.String dbURL,
                              java.lang.String userName,
                              java.lang.String password,
                              int maxConnections,
                              long expiration,
                              boolean debug)
        Constructor
    • Method Detail

      • getConnection

        public WrappedConnection getConnection()
                                        throws java.sql.SQLException,
                                               java.lang.InterruptedException
        Obtain a connection from the pool. This will wait until a connection is free, if the pool is already completely tapped. The connection is returned by the "close" operation, executed on the connection. (This requires us to wrap the actual connection object).
        Throws:
        java.sql.SQLException
        java.lang.InterruptedException
      • flushPool

        public void flushPool()
        Flush the pool.
      • closePool

        public void closePool()
        Close down the pool.
      • cleanupExpiredConnections

        public void cleanupExpiredConnections​(long currentTime)
        Clean up expired connections.
      • releaseConnection

        public void releaseConnection​(WrappedConnection connection)
      • release

        protected void release​(java.sql.Connection c)