Java DB Conn Pool

我要开发同款
匿名用户2010年01月07日
42阅读
开发技术Java
所属分类程序开发、数据库连接池
授权协议未知

作品详情

JavaDBConnPool是一个Java的数据库连接池组件。

使用示例代码:

publicclassTestPool{publicstaticvoidmain(String[]args){DataSourceds=null;//PrintWriterlog=null;//uncommenttoturnonloggingtry{//log=newPrintWriter(newFileWriter("dblog"),true);//uncommenttoturnonloggingPropertiesp=newProperties();p.setProperty("logLevel","1");//debug=4,info=3,warn=2,error=1,fatal=0p.setProperty("autoCommit","false");p.setProperty("description","Oracle");p.setProperty("driverClass","oracle.jdbc.driver.OracleDriver");p.setProperty("maxCount","2");p.setProperty("minCount","1");p.setProperty("user","test");p.setProperty("password","test");p.setProperty("url","jdbc:oracle:thin:@127.0.0.1:1565:test");p.setProperty("loginTimeout","0");//insecondsp.setProperty("holdTimeout","1000");//insecondsp.setProperty("waitTimeout","10000");//inmillisecondsp.setProperty("checkQuery","selectSYSDATEfromdual");p.setProperty("statementCacheSize","10");//ds=newRPDataSource(p,log);//usethisinsteadofthenextlinetoturnonloggingds=newRPDataSource(p);Connectioncon=ds.getConnection();Statements=con.createStatement();ResultSetrs=s.executeQuery("selectSYSDATEfromdual");if(rs.next()){System.out.println(rs.getString(1));}rs.close();s.close();con.close();con=ds.getConnection();s=con.createStatement();rs=s.executeQuery("selectSYSDATEfromdual");if(rs.next()){System.out.println(rs.getString(1));}}catch(Exceptione){e.printStackTrace();}finally{try{RPDataSourcerp=(RPDataSource)ds;rp.destroy();}catch(Exceptione){e.printStackTrace();}}}}
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论