DBCP数据源的使用
DBCP(DataBase Connection Pool)是一个开源的数据源工具,实际开发直接使用就行了
导入需要的jar包,数据库使用mysql测试
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPwAAABWCAIAAABkTmy4AAANXUlEQVR4nO2d63MT1xnG9aX/R7+UGUImbacDDQK3gMkMHabMZDrMwFDST1FKh2m5tIEUCDgBrJibDA0wtusLLoY4GGJjFENiZAMmjmPL6GJbsmzriiVbkqWVdbENZvthZWl3zzm7K1mXXe95Zsdjr95z9t3dR++eXZ2fpSCxsGSg/v5+52ScWhTFTgYLqxDCpseSnYpv+sTkQMz5LKdd2jRKhUKhUGlz2mt20qoUSo2NN8ymUSbjbBpljjJP94nFUDFN/2bxtbdNZa9a72rcxhmYNHFSfOcxd67JheCmB3LEpi+gilzpHTUlU63vuBtLFwg3OorhA62Kp4YLrK0FkkDTC3oJKzfKmel1Op1arUa9+n5588++NNGX98ubSZIMD9542bxhsuXdwPMv0X0zfaBVYdNjLUe5MX1nZ+eaNWtWrVqFClj71yvgQpLkfHDcdnVj4Nu3Rq+992bxNaI13Qesa7ZWxRz1pP9OtmAHLPWmVaVXgTFalUKp0aiA8RQ0Ehx20bKAj8egwxtqBS092m5A0qYN+uAxwAWSlQ6kA3koB6anHL9r1y4O05Mk+cc7ZdDFfvMvky2/HKveRFh0iKb0MT3dQfQqmj7DtLXQAKo3uhvAGK0qFZJ+l2lVbAMj2zK8lrnp0x2kO2OlbdOolrpFxUAPSWqtjK8oyzV9yvG7d+/mNv2GhsNHO46zlg0Nh0Mm7dh/t3ia3x6/fQDRlHH2YMWLXeyBCk4PAAZLkBiWS4B1HG1ZYRncyNIrPfgCxKRAqWbGMN/CsH2EX4ZWvJZlerrjeU3/88oPoMvifGzg5NpAx2p9mfJVNARrSj+XNNsjBu8M0/MaDh4j2PRg28KY3qZRpgyLaks3PdLb1BtHXtZflunVavUqms6ePYuK7Ni/lWOx1P3N0fi25eo6T2cdrDXjXNIG9ay6D74XoAEsV0Fj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UCyQb33a9BmgsTwHkbkCueXUX4xaL4o5+KJmZCnJkZHNwPS8W19WpYccROZOIE0vDJwtijAjK05GlouFRWwFtT4LNJb7m19pYxrGgE0y4KwEnt7IkpHlIFxzciPLh8aCoyHG8B1IP1twtiiSwHN6WTKyojBHNpJC4hL4RFaWjKwUvAOTFD6QlYLpZcnIStD00gFnJWB6LKzcCpseS3bCpseSnbDpsWQnbHos2QmbHkt2wqbHkp2Kb/rE5EDM+SyPG5DE5yVYBVQxTf9m8bW3TWWvWu9q3MYfDZ/CRZIkH8oj3PT0iYFYK1fLNb3wKTRQOWpKplrfcTeWLhBuntCsTc+I4/4KmhX1balYKNFN/39WThcZ6mB/sgAAAABJRU5ErkJggg==" alt="" />
配置文件就是一个properties文件,key-value值按规范写就行了
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/blogs_stu
username=root
password=
#初始化连接数
initialSize=10
#最大连接数
maxActive=50
#最大空闲连接
maxIdle=20
#最小空闲连接
minIdle=5
//超时等待时间,单位为毫秒
maxWait=60000 #附带的连接属性
connectionProperties=useUnicode=true;characterEncoding=utf8
#事物默认自动提交
defaultAutoCommit=true
#设置数据库是否为只读,不设置表示否
defaultReadOnly=
#设置事物的隔离级别。可选值NONE,READ_UNCOMMITTED,READ_COMMITTED,REPEATABLE_READ,SERIALIZABLE
#一般都是选REPEATABLE_READ,能避免脏读,不可重复读,但可能会虚读(为了性能这点牺牲还是值得的)
defaultTransactionIsolation=REPEATABLE_READ
工具类DBCPUtil
public class DBCPUtil {
private static DataSource ds;
static{
try {
InputStream is=DBCPUtil.class.getClassLoader().getResourceAsStream("dbcpconfig.properties");
Properties p=new Properties();
p.load(is);
ds=BasicDataSourceFactory.createDataSource(p);
} catch (Exception e) {
e.printStackTrace();
}
}
public static Connection getConnection(){
try {
return ds.getConnection();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
public static void release(Connection conn,Statement stmt,ResultSet rs){
if(conn!=null){
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
conn=null;
}
if(stmt!=null){
try {
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
stmt=null;
}
if(rs!=null){
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
rs=null;
}
}
}
测试下打印一下该Connection对象,会发现其实该工具就是使用了一个包装类包装了原有的Connection接口实现类,
扩展了close方法,以实现将用完的Connection对象放回连接池中
public class Test6{
public static void main(String[] args) throws SQLException {
Connection conn=DBCPUtil.getConnection();
System.out.println(conn.getClass().getName());
}
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAjQAAABMCAIAAAD1B7rRAAAViElEQVR4nO1d23MU55Wfvyeufdm3be+bpdTuf7BblezDPjSl2pgYp1yVdWVrk9p4y3lwMlwkQLC2cWJFlGWwAbcGhBKBA5IAGRCSkDQIEDC6z0Vzv4nZh759l3O+7p6L1BLnV+eh9c13Ped853f6m1F3ZHmluLxSbDQa+WJdkLM3LpfyN4q5G6XCzU/HjXyxfvTkrXyxPhtPnLs8c+7yo3OXHs0sLMsN8/OjvX39vX2jc27h0nDf0PiqeZ0cH+wfnrcu3Grzo72DUwmugo9Wq1MD3ECiJNO5VK7Eyls//fQ/fnn0frKWyhST6cJmKr+RzK1vZtc2Mutb241G490Pj7/100+FVinjvUjXyYdCYa6Uyl39WSTyzokFt1rkvct2eeTw1VSulJo9+U6k++iseWF+6qe5c9F9dNasvHC0K/IzQ56DJY1Go6enp8Ggp6cHq2xKMp1zdHXturFeqJUL+XKpXKnubBdr6UItma9t5WoPn6TWstVHiy/jz9YRVSfHB21jrU4NWIbjjVVcGu7rH5hIMn5ifiR5gnW9NOxeyJ6wNNzXb/mM6XKxJc4lvHwDlD9cmZ5/lRmbWfnwy8l0vrKQyHz45eTSWrZQrl+fTqjasg4cMy+YtQDuDVUrLg33mZ/W88X6XMxeIKo6vtyH3Lp6OpWrLa/n/zgyk8rVLn7/5E8jc78fmkzlas9nxiZjx/C2zszlEtRA/Nwcg4JrF7wFrWP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iEAgEQuhA5EQgEAiE0IHIiUAgEAihA5ETgUAgEEIHIicCgUAghA5ETgQCgUAIHYicCAQCgRA6EDkRCAQCIXQgciIQCARC6EDkRCAQCITQgciJQCAQCKHD/wNRdXOeKeSopQAAAABJRU5ErkJggg==" alt="" />
所以如果调用DBCPUtil中的close方法其实是调用包装类中扩展的close方法,该方法将Connection对象放回连接池。
DBCP数据源的使用的更多相关文章
- DBCP数据源连接池实现原理分析
前些天在调试公司系统的时候发现这样的一个问题:mysql数据库服务停止一段时间后再次重启后吗,tomcat服务无法请求数据库服务,调试了半天对这个问题进行定位解决,期间也搞了很多有关mysql数据库的 ...
- JDBC 学习笔记(三)—— 数据源(数据库连接池):DBCP数据源、C3P0 数据源以及自定义数据源技术
本文目录: 1.应用程序直接获取连接的缺点(图解) 2.使用数据库连接池优化程序性能(图解) 3.可扩展增强某个类方法的功能的三种方式 4.自定 ...
- DBCP数据源
DBCP数据源是Apache软件基金组织下的开源连接池实现,需要两个jar文件:Commons-dbcp.jar 连接池的实现和Commons-pool.jar 连接池实现的依赖库
- CP30,DBCP数据源配置
Spring中 CP30数据源配置 <!-- 加载属性文件 01--> <bean id= "propertyConfigurer" class="or ...
- dbcp数据源连接池
一.数据源连接池 我们之前利用jdbc连接数据库,每次都要创建连接对象,销毁连接对象,如果并发访问量比较大,这样肯定比较辣 浪费数据库的效率,我们可以像之前mybatis中缓存查询到的数据一样,可以把 ...
- dbcp数据源配置杂谈
<!-- 数据源1 --> #驱动信息(driver, url, username, password)driverClassName=net.sourceforge.jtds.jdbc. ...
- 最新版本的DBCP数据源配置
弄了我一下午,把该加的包都加进去了还是没用,后来把DBCP的包打开来看看才发现路径不对.配置如下: <!-- 使用dbcp配置数据源 --> <bean id="dataS ...
- dbcp数据源配置
<bean id="dbcpDataSource" class="org.apache.commons.dbcp.BasicDataSource" de ...
- DBCP数据源使用
DBCP:DataBase Connection Pool 1.须要的jar:commons-dbcp.jar commons-pool.jar 2.把DBCP的配置文件(dbcpconfig.pr ...
随机推荐
- DeviceIoControl方式 sys和exe通信
常识: IRP:I/O Request Package 即输入输出请求包 exe和sys通信时,exe会发出I/O请求.操作系统会将I/O请求转化为相应的IRP数据, 不同类型传递到不同的d ...
- 【译】TensorFlow Python Docs 之 overview
Overview 综述 TensorFlow has APIs available in several languages both for constructing and executing a ...
- 【ADO.Excel】ADO获取excel的Sheet集合
using (OleDbConnection connection = new OleDbConnection(GetConnectionString())) { connection.Open(); ...
- WampServer Mysql配置
WAMP:Windows下的Apache+Mysql+Perl/PHP/Python,一组常用来搭建动态网站或者服务器的开源软件.可点击此处下载WampServer,然后,按照提示安装WAMP.需要说 ...
- 什么时候用spring
论公司spring的滥用 这个公司每个项目用不同的一套开发框架,实在忍不住拿一个出来说说事.
- 常用PHP正则表达式
获取所有图片网址preg_match_all(“/ src=(\”|\’){0,}(http:\/\/(.+?))(\”|\’|\s|>)/is”,$text,$img); 匹配中文字符的正则表 ...
- launch failed.Binary not found
1.在eclipse官网中下载已经集成了CDT的eclipse.(http://www.eclipse.org/downloads/download.php?file=/technology/epp/ ...
- Embedded Linux Primer----嵌入式Linux基础教程--导论
第一章 导论 在这一章里(将要学习到) 为什么是Linux 嵌入式Linux现状 开源和GPL(译者:通用公共许可证) 标准和有关团体 本章总结 放弃专有操作系统正在许多传统嵌入式操作系统公司引起一阵 ...
- 通过Shell脚本读取properties文件中的参数时遇到\r换行符的问题
今天在编写微服务程序启动脚本的时候,遇到一个比较奇葩的问题,下面给出具体描述: 目标:通过读取maven插件打包时生成的pom.properties文件,获取里面的应用名称和应用版本号,然后拼接得到s ...
- javascript 数组方法解析
测试数组:testArrayA = ['a','b','c','d','e'] , testArrayB = [2,3,6,1] 1.删除数组最后一项(pop()): 返回删除那一项的值:var po ...