一个连接池的例子(来自JIVE)(4)
发布时间:2019-10-13 编辑:jiaochengji.com
教程集为您提供一个连接池的例子(来自JIVE)(4)等资源,欢迎您收藏本站,我们将为您提供最新的一个连接池的例子(来自JIVE)(4)资源
package com.qingtuo.db.pool;
import java.sql.*;
import java.io.*;
import java.util.*;
/**
* Central manager of database connections.
*/
public class DbConnectionManager {
private static DbConnectionProvider connectionProvider;
private static Object providerLock = new Object();
/**
* Returns a database connection from the currently active connection
* provider.
*/
public static Connection getConnection() {
if (connectionProvider == null) {
synchronized (providerLock) {
if (connectionProvider == null) {
//Create the connection provider -- for now, this is hardcoded. For
//the next beta, I'll change this to load up the provider dynamically.
connectionProvider = new DbConnectionDefaultPool();
connectionProvider.start();
}
}
}
Connection con = connectionProvider.getConnection();
您可能感兴趣的文章:
一个连接池的例子(来自JIVE)(6)
一个连接池的例子(来自JIVE)(1)
一个连接池的例子(说明)
一个连接池的例子(来自JIVE)(4)
一个连接池的例子(来自JIVE)(5)
一个连接池的例子(来自JIVE)(3)
一个连接池的例子(来自JIVE)(2)
用连接池提高Servlet访问数据库的效率
使用JAVA中的动态代理实现数据库连接池
数据库中的长连接和短连接区别分析
[关闭]