ProgramixGenericLib v5.0.1

com.programix.sql
Class BottomlessConnectionPool

java.lang.Object
  extended by com.programix.sql.BottomlessConnectionPool

public class BottomlessConnectionPool
extends Object

Sets up a simple, thread-safe, bottomless database connection pool. When the pool is empty, checkOut() always attempts to create an additional connection. The "max idle count" value is used to indicate the maximum number of idle connections kept in the pool; as checkins occur beyond this level, those connections are automatically closed.

The ValueMap passed can be created from a file that looks something like this:

 sql.connection.pool.driver=org.hsqldb.jdbcDriver
 sql.connection.pool.url=jdbc:hsqldb:hsql://localhost:3500
 sql.connection.pool.username=appuser
 sql.connection.pool.password=secret
 sql.connection.pool.max.idle.count=5
 
Where the "max idle count" is optional.

Author:
Paul Hyde

Field Summary
static int DEFAULT_MAX_IDLE_COUNT
           
static String DRIVER_KEY
           
static String MAX_IDLE_COUNT_KEY
           
static String PASSWORD_KEY
           
static String URL_KEY
           
static String USERNAME_KEY
           
 
Constructor Summary
BottomlessConnectionPool(Map<?,?> config)
          Converts the Map to a ValueMap and calls the main constructor.
BottomlessConnectionPool(ValueMap config)
           
 
Method Summary
 void checkIn(Connection con)
          Returns the specified connection to the pool.
 Connection checkOut()
           
 void close()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DRIVER_KEY

public static final String DRIVER_KEY
See Also:
Constant Field Values

URL_KEY

public static final String URL_KEY
See Also:
Constant Field Values

USERNAME_KEY

public static final String USERNAME_KEY
See Also:
Constant Field Values

PASSWORD_KEY

public static final String PASSWORD_KEY
See Also:
Constant Field Values

MAX_IDLE_COUNT_KEY

public static final String MAX_IDLE_COUNT_KEY
See Also:
Constant Field Values

DEFAULT_MAX_IDLE_COUNT

public static final int DEFAULT_MAX_IDLE_COUNT
See Also:
Constant Field Values
Constructor Detail

BottomlessConnectionPool

public BottomlessConnectionPool(ValueMap config)
                         throws SQLException
Throws:
SQLException

BottomlessConnectionPool

public BottomlessConnectionPool(Map<?,?> config)
                         throws SQLException
Converts the Map to a ValueMap and calls the main constructor. Equivalent to:
 this(ValueMap.ValueMap.createFrom(Map)createFrom(config));
 

Throws:
SQLException
Method Detail

checkOut

public Connection checkOut()
                    throws SQLException
Throws:
SQLException

checkIn

public void checkIn(Connection con)
Returns the specified connection to the pool. If con is null, the check-in request is silently ignored.


close

public void close()

ProgramixGenericLib v5.0.1

Copyright © 2001-2009 Programix Incorporated. All rights reserved. ProgramixGenericLib is free and is OSI Certified Open Source Software under the BSD license.