BoneCP :: Core Library 0.7.1.RELEASE API

This document describes the API of BoneCP.

See:
          Description

Packages
com.jolbox.bonecp The core package for the BoneCP connection pool.
com.jolbox.bonecp.hooks Support for event notification on a connection state.
com.jolbox.bonecp.proxy For internal use only.
jsr166y  

 

This document describes the API of BoneCP. Usage is simple:

The example below sets up the connection pool (manually) and obtains a connection. For clarity it omits exception handling.
     
// load the database driver (make sure this is in your classpath!)
Class.forName("org.hsqldb.jdbcDriver");
// setup the connection pool
BoneCPConfig config = new BoneCPConfig();
// jdbc url specific to your database, eg jdbc:mysql://127.0.0.1/yourdb
config.setJdbcUrl("jdbc:hsqldb:mem:test"); 
config.setUsername("sa"); 
config.setPassword("");
config.setMinConnectionsPerPartition(5);
config.setMaxConnectionsPerPartition(10);
config.setPartitionCount(1);
        
connectionPool = new BoneCP(config); // setup the connection pool
                        
connection = connectionPool.getConnection(); // fetch a connection
if (connection != null){
        System.out.println("Connection successful!");
    Statement stmt = connection.createStatement();
    // do something with the connection.
        ResultSet rs = stmt.executeQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS"); 
        while(rs.next()){
                System.out.println(rs.getString(1)); // should print out "1"'
        }
}
                        
connection.close(); // close the connection
connectionPool.shutdown(); // shutdown connection pool.
        



Copyright © 2009-2011 JolBox. All Rights Reserved.