|
||||||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||||
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:
// 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.
|
||||||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||||