浏览 2034 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2014-08-12
最后修改:2014-08-12
org.jivesoftware.openfire.auth.JDBCAuthProvider private static ProxoolDataSource pds; //连接池对象 private Connection getConnection() throws SQLException { if (useConnectionProvider) return DbConnectionManager.getConnection(); //这里是使用jdk自带的方法,需要修改为连接池取法 //return DriverManager.getConnection(connectionString); if(pds == null){ //配置是读取ofProperty获取的 connectionString = JiveGlobals.getProperty("jdbcProvider.connectionString"); pds = new ProxoolDataSource(); pds.setDriver(JiveGlobals.getProperty("jdbcProvider.driver")); pds.setDriverUrl(connectionString); pds.setUser(JiveGlobals.getProperty("jdbcAuthProvider.jdbcUserName")); pds.setPassword(JiveGlobals.getProperty("jdbcAuthProvider.jdbcUserPassword")); pds.setMinimumConnectionCount(JiveGlobals.getIntProperty("jdbcAuthProvider.minimumConnectionCount",10)); pds.setMaximumConnectionCount(JiveGlobals.getIntProperty("jdbcAuthProvider.maximumConnectionCount",20)); pds.setPrototypeCount(JiveGlobals.getIntProperty("jdbcAuthProvider.prototypeCount",20)); pds.setMaximumActiveTime(JiveGlobals.getIntProperty("jdbcAuthProvider.maximumActiveTime",900000)); pds.setMaximumConnectionLifetime(JiveGlobals.getIntProperty("jdbcAuthProvider.maximumConnectionLifetime",14400000)); } long conectionGetStartTime = System.currentTimeMillis(); Connection connection = pds.getConnection(); long conectionGetEndTime = System.currentTimeMillis(); Log.info("获得连接时间 : "+(conectionGetEndTime - conectionGetStartTime ) + " , 连接对象: "+connection.toString()); return connection; } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |