com.jolbox.bonecp
Class BoneCP

java.lang.Object
  extended by com.jolbox.bonecp.BoneCP
All Implemented Interfaces:
java.io.Serializable

public class BoneCP
extends java.lang.Object
implements java.io.Serializable

Connection pool (main class).

Author:
wwadge
See Also:
Serialized Form

Field Summary
static java.lang.String MBEAN_BONECP
          JMX constant.
static java.lang.String MBEAN_CONFIG
          JMX constant.
 
Constructor Summary
BoneCP(BoneCPConfig config)
          Constructor.
 
Method Summary
 void close()
          Just a synonym to shutdown.
 java.util.concurrent.Future<java.sql.Connection> getAsyncConnection()
          Obtain a connection asynchronously by queueing a request to obtain a connection in a separate thread.
 BoneCPConfig getConfig()
          Gets config object.
 java.sql.Connection getConnection()
          Returns a free connection.
 Statistics getStatistics()
          Returns a reference to the statistics class.
 int getTotalCreatedConnections()
          Return total number of connections created in all partitions.
 int getTotalFree()
          Return the number of free connections available to an application right away (excluding connections that can be created dynamically)
 int getTotalLeased()
          Return total number of connections currently in use by an application
 boolean isConnectionHandleAlive(ConnectionHandle connection)
          Sends a dummy statement to the server to keep the connection alive
 void shutdown()
          Closes off this connection pool.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MBEAN_CONFIG

public static final java.lang.String MBEAN_CONFIG
JMX constant.

See Also:
Constant Field Values

MBEAN_BONECP

public static final java.lang.String MBEAN_BONECP
JMX constant.

See Also:
Constant Field Values
Constructor Detail

BoneCP

public BoneCP(BoneCPConfig config)
       throws java.sql.SQLException
Constructor.

Parameters:
config - Configuration for pool
Throws:
java.sql.SQLException - on error
Method Detail

shutdown

public void shutdown()
Closes off this connection pool.


close

public void close()
Just a synonym to shutdown.


getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Returns a free connection.

Returns:
Connection handle.
Throws:
java.sql.SQLException

getAsyncConnection

public java.util.concurrent.Future<java.sql.Connection> getAsyncConnection()
Obtain a connection asynchronously by queueing a request to obtain a connection in a separate thread. Use as follows:

Future<Connection> result = pool.getAsyncConnection();

... do something else in your application here ...

Connection connection = result.get(); // get the connection

Returns:
A Future task returning a connection.

isConnectionHandleAlive

public boolean isConnectionHandleAlive(ConnectionHandle connection)
Sends a dummy statement to the server to keep the connection alive

Parameters:
connection - Connection handle to perform activity on
Returns:
true if test query worked, false otherwise

getTotalLeased

public int getTotalLeased()
Return total number of connections currently in use by an application

Returns:
no of leased connections

getTotalFree

public int getTotalFree()
Return the number of free connections available to an application right away (excluding connections that can be created dynamically)

Returns:
number of free connections

getTotalCreatedConnections

public int getTotalCreatedConnections()
Return total number of connections created in all partitions.

Returns:
number of created connections

getConfig

public BoneCPConfig getConfig()
Gets config object.

Returns:
config object

getStatistics

public Statistics getStatistics()
Returns a reference to the statistics class.

Returns:
statistics


Copyright © 2009-2011 JolBox. All Rights Reserved.