六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 198|回复: 0

Java连接池 BoneCP 0.7.0

[复制链接]

升级  60%

6

主题

6

主题

6

主题

童生

Rank: 1

积分
30
 楼主| 发表于 2013-1-14 23:43:34 | 显示全部楼层 |阅读模式
今天看到BoneCP 0.7.0 正式版发布了,就来看了一下
首先介绍一下BoneCP 0.7.0
<div class="NewsContent TextContent">BoneCP 0.7.0 版本包含众多改进和调整,另外授权协议由 LGPL 改为 Apache
详情包括:

Features:
+ 新架构使得连接池性能更佳
+ 授权协议由LGPL改为Apache
+ OSGi 支持
+ Add maxConnectionAge to give a maximum time a connection will be kept alive.
+ Add ability to load default XML config file (with overrides)
+ Added onBeforeStatementExecute and onAfterStatementExecute hooks.
+ Added connection/statement handles to onQueryTimeLimitExeceeded (deprecated old version)
+ Support for LIFO queues for better idleConnectionTimeouts.

Fixes
+ Make connectionTimeout 0 behave like max value
+ Don't set username to blank if it is null and respect datasource bean setting
+ Allow minConnections = 0
+ Fixes for hibernate provider (https://bugs.launchpad.net/bonecp/+bug/655288)
+ Pass StatementHandle reference to hook rather than Statement
+ Use StringBuilder where necessary for better performance.1
+ Failures in closing a connection might cause connection to be lost.
+ Other minor cleanups.

Compatibility notes
+ set default partition count to 1
+ Migrated from Google collections library to Google guava
官网 http://jolbox.com/
下载地址:http://jolbox.com/bonecp/downloads/maven/com/jolbox/
API    http://jolbox.com/bonecp/downloads/site/apidocs/index.html
在API中给了这么demo
 
// load the database driver (make sure this is in your classpath!)Class.forName("org.hsqldb.jdbcDriver");// setup the connection poolBoneCPConfig config = new BoneCPConfig();// jdbc url specific to your database, eg jdbc:mysql://127.0.0.1/yourdbconfig.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 connectionif (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 connectionconnectionPool.shutdown(); // shutdown connection pool. 
自己还是需要进行修改。
这里我附上自己写的一个demo里面含有jar包 和一个数据库sqlitejdbc-v056.jar
两个执行类,一个是对SQL Server2000操作的。
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表