hibernate连接池Word下载.docx

上传人:b****2 文档编号:15059765 上传时间:2022-10-27 格式:DOCX 页数:14 大小:24.24KB
下载 相关 举报
hibernate连接池Word下载.docx_第1页
第1页 / 共14页
hibernate连接池Word下载.docx_第2页
第2页 / 共14页
hibernate连接池Word下载.docx_第3页
第3页 / 共14页
hibernate连接池Word下载.docx_第4页
第4页 / 共14页
hibernate连接池Word下载.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

hibernate连接池Word下载.docx

《hibernate连接池Word下载.docx》由会员分享,可在线阅读,更多相关《hibernate连接池Word下载.docx(14页珍藏版)》请在冰豆网上搜索。

hibernate连接池Word下载.docx

下面是Hibernate环境下几种常见的连接池配置:

1.Hibernate默认连接池

<

?

xmlversion='

1.0'

encoding='

UTF-8'

>

!

DOCTYPEhibernate-configuration

PUBLIC"

-//Hibernate/HibernateConfigurationDTD//EN"

"

hibernate-configuration>

session-factory>

—JDBC驱动程序-->

propertyname="

connection.driver_class"

com.mysql.jdbc.Driver<

/property>

--连接数据库的URL-->

connection.url"

jdbc:

mysql:

//localhost:

3306/schoolproject

connection.useUnicode"

true<

connection.characterEncoding"

UTF-8<

--连接的登录名-->

connection.username"

root<

—登录密码-->

connection.password"

--是否将运行期生成的SQL输出到日志以供调试-->

show_sql"

--指定连接的语言-->

dialect"

org.hibernate.dialect.MySQLDialect<

--映射Student这个资源-->

mappingresource="

com/wqbi/model/pojo/student.hbm.xml"

/>

/session-factory>

/hibernate-configuration>

2.C3P0连接配置

--登录密码-->

--C3P0连接池设定-->

p

hibernate.connection.provider_class"

org.hibernate.connection.C3P0ConnectionProvider

hibernate.c3p0.max_size"

20<

hibernate.c3p0.min_size"

5<

hibernate.c3p0.timeout"

120<

hibernate.c3p0.max_statements"

100<

hibernate.c3p0.idle_test_period"

hibernate.c3p0.acquire_increment"

2<

3.proxool连接池

(1)先写proxool的配置文件,文件名:

proxool.xml(一般放在与hibernate.cfg.xml文件在同一个目录中)本例配置的是MYSQL数据库,数据库的名字为schoolproject

xmlversion="

1.0"

encoding="

UTF-8"

--theproxoolconfigurationcanbeembeddedwithinyourownapplication'

s.

Anythingoutsidethe"

proxool"

tagisignored.-->

something-else-entirely>

proxool>

--连接池的别名-->

alias>

DBPool<

/alias>

--proxool只能管理由自己产生的连接-->

driver-url>

3306/schoolproject?

useUnicode=true&

amp;

characterEncoding=UTF8

/driver-url>

driver-class>

/driver-class>

driver-properties>

user"

value="

root"

/>

password"

/driver-properties>

--proxool自动侦察各个连接状态的时间间隔(毫秒),侦察到空闲的连接就马上回

收,超时的销毁-->

house-keeping-sleep-time>

90000<

/house-keeping-sleep-time>

--指因未有空闲连接可以分配而在队列中等候的最大请求数,超过这个请求数的

用户连接就不会被接受-->

maximum-new-connections>

/maximum-new-connections>

--最少保持的空闲连接数-->

prototype-count>

/prototype-count>

--允许最大连接数,超过了这个连接,再有请求时,就排在队列中等候,最大的

等待请求数由maximum-new-connections决定-->

maximum-connection-count>

/maximum-connection-count>

--最小连接数-->

minimum-connection-count>

10<

/minimum-connection-count>

/proxool>

/something-else-entirely>

(2)配置hibernate.cfg.xml文件

org.hibernate.connection.ProxoolConnectionProvider

hibernate.proxool.pool_alias"

hibernate.proxool.xml"

proxoolconf.xml<

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 外语学习 > 韩语学习

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1