hibernate 配置链接池
来源:互联网 发布:孕傻 知乎 编辑:程序博客网 时间:2024/05/16 06:28
在做一个项目的时候,发现一个问题在本机测试都ok 但是发布到生产机上就出了问题 。
提示链接不到数据库 用的mysql 。
后来发现了是mysql 设置的链接时间 比较短
考虑一下 把数据库的链接 改成了 连接池的方式
问题 解决了
下面 把Hibernate数据库连接池的代码贴出来
proxoolconf.xml 放在 src 的根目录
- < ?xml version="1.0" encoding="UTF-8"?>
- < !-- the proxool configuration can be embedded within your own application's.
- Anything outside the "proxool" tag is ignored. -->
- < something-else-entirely>
- < proxool>
- < !--连接池的别名-->
- < alias>DBPool< /alias>
- < !--proxool只能管理由自己产生的连接-->
- < driver-url>
- jdbc:mysql://121.199.27.237:3306/zp11a1_db?useUnicode=true&characterEncoding=GBK
- < /driver-url>
- < !-- -->JDBC驱动程序-->
- < driver-class>com.mysql.jdbc.Driver< /driver-class>
- < driver-properties>
- < property name="user" value="zp11a1"/>
- < property name="password" value="k6c5t6h4v4"/>
- < /driver-properties>
- < !-- proxool自动侦察各个连接状态的时间间隔(毫秒),侦察到空闲的连接就马上回收,超时的销毁-->
- < house-keeping-sleep-time>90000< /house-keeping-sleep-time>
- < !-- 指因未有空闲连接可以分配而在队列中等候的最大请求数,超过这个请求数的用户连接就不会被接受-->
- < maximum-new-connections>20< /maximum-new-connections>
- < !-- 最少保持的空闲连接数-->
- < prototype-count>5< /prototype-count>
- < !-- 允许最大连接数,超过了这个连接,再有请求时,就排在队列中等候,最大的等待请求数由maximum-new-connections决定-->
- < maximum-connection-count>100< /maximum-connection-count>
- < !-- 最小连接数-->
- < minimum-connection-count>10< /minimum-connection-count>
- < /proxool>
- < /something-else-entirely>
- hibernate.cfg.xml 的配置 如下
- < ?xml version='1.0' encoding='UTF-8'?>
- < !DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
- < hibernate-configuration>
- < session-factory>
- < property name="hibernate.connection.provider_class">
- org.hibernate.connection.ProxoolConnectionProvider
- < /property>
- < property name="hibernate.proxool.pool_alias">DBPool< /property>
- < property name="hibernate.proxool.xml">
- proxoolconf.xml
- < /property>
- < !--是否将运行期生成的SQL输出到日志以供调试-->
- < property name="show_sql">true< /property>
- < !--指定连接的语言-->
- < property name="dialect">
- org.hibernate.dialect.MySQLDialect
- < /property>
- < !--映射Student这个资源-->
- < mapping resource="com/bsoar/hibernate/pojo/Cancellation.hbm.xml" />
- < mapping resource="com/bsoar/hibernate/pojo/Arrearage.hbm.xml" />
- < mapping resource="com/bsoar/hibernate/pojo/Role.hbm.xml" />
- < mapping resource="com/bsoar/hibernate/pojo/CustomerInfo.hbm.xml" />
- < mapping resource="com/bsoar/hibernate/pojo/Notice.hbm.xml" />
- < mapping resource="com/bsoar/hibernate/pojo/Function.hbm.xml" />
- < mapping resource="com/bsoar/hibernate/pojo/Employee.hbm.xml" />
- < mapping resource="com/bsoar/hibernate/pojo/TOrder.hbm.xml" />
- < mapping resource="com/bsoar/hibernate/pojo/PriceFile.hbm.xml" />
- < mapping resource="com/bsoar/hibernate/pojo/PolicyFile.hbm.xml" />
- < /session-factory>
- < /hibernate-configuration>
0 0
- hibernate 配置链接池
- hibernate链接数据库链接池c3p0配置
- spring+hibernate+c3p0整合链接池配置-连接无法释放问题(已经解决)
- spring+hibernate+c3p0整合链接池配置-连接无法释放问题(已经解决)
- spring+hibernate+c3p0整合链接池配置-连接无法释放问题(已经解决)
- Hibernate 链接
- hibenate配置链接池
- 配置c3p0链接池
- 如何在spring配置多个Hibernate数据源链接
- Hibernate配置Myeclipse与SQL Server 2008链接
- Hibernate连接池配置
- Hibernate连接池配置
- Hibernate连接池配置
- hibernate连接池配置
- Hibernate连接池配置
- 配置hibernate连接池
- hibernate连接池配置
- hibernate 配置连接池
- JS未结束的字符串常量
- cocos2dx3.2开发 RPG《Flighting》(一)基本介绍
- 找零方案
- cocos2dx3.3在Win7(64位)上Android开发环境搭建(提要)
- 固定时间触发
- hibernate 配置链接池
- AJAX提交与FORM提交的区别
- vmware ubuntu上不了网的解决办法
- js-常用替换“单引号”、“双引号”、“尖括号
- 数据库Text字段中,取出显示想让文本有段落,缩进等,就像我们写的文章一样有格式
- 趣谈软硬件设计
- golang中os/signal包的使用
- 让手机重现“一律允许使用这台计算机进行调试”确认窗口
- 基于有限状态机的交互组件设计与实现