BoneCP 配置 方法 记录

Tomcat 下配置方法
ENV:   
1.环境:jdk1.6,tomcat6.0.20,bonecp-0.6.4
2.需要的包:google-collections-1.0.jar,slf4j-api-1.5.11.jar,slf4j-log4j12-1.5.11.jar,bonecp-0.6.4.jar

STEP:
<Resource
name="clientdb"
auth="Container"
type="com.jolbox.bonecp.BoneCPDataSource"
factory="org.apache.naming.factory.BeanFactory"
driverClass="oracle.jdbc.driver.OracleDriver"
username=" "
password=" "
jdbcUrl="jdbc:oracle:thin:@127.0.0.1:1521:DB"
idleConnectionTestPeriod="0"
idleMaxAge="10"
partitionCount="1"
maxConnectionsPerPartition="5"
minConnectionsPerPartition="1"
connectionTestStatement=""
initSQL="select 1 from dual"
/>
可以放到conf/server.xml文件的 <GlobalNamingResources>节,也可放到<context>中

Use Ways:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup(JNDIName);
con = ds.getConnection();

Resources:
http://jolbox.com/bonecp/downloads/maven/com/jolbox/bonecp/0.6.4/bonecp-0.6.4.jar
http://google-collections.googlecode.com/files/google-collect-1.0.zip
http://www.slf4j.org/dist/slf4j-1.5.11.zip



你可能感兴趣的:(职场,记录,bonecp,休闲)