Hibernate整合连接池
来源:互联网 发布:小程序 post php接收 编辑:程序博客网 时间:2024/06/11 17:06
整合c3p0(连接池)
整合c3p0:
步骤一:导入c3p0 jar包
步骤二:hibernate.cfg.xml 配置
hibernate.connection.provider_classorg.hibernate.connection.C3P0ConnectionProvider
c3p0具体配置参数:
###########################
### C3P0 Connection Pool###
###########################
#hibernate.c3p0.max_size 2
#hibernate.c3p0.min_size 2
#hibernate.c3p0.timeout 5000
#hibernate.c3p0.max_statements 100
#hibernate.c3p0.idle_test_period 3000
#hibernate.c3p0.acquire_increment 2
#hibernate.c3p0.validate false
配置:
<!--告诉Hibernate,我要使用C3p0连接池 hibernate.connection.provider_class org.hibernate.connection.C3P0ConnectionProvider --><property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property><!-- #hibernate.c3p0.max_size 2#hibernate.c3p0.min_size 2#hibernate.c3p0.timeout 5000#hibernate.c3p0.max_statements 100#hibernate.c3p0.idle_test_period 3000#hibernate.c3p0.acquire_increment 2#hibernate.c3p0.validate false --> <property name="hibernate.c3p0.max_size">5</property> <property name="hibernate.c3p0.min_size">2</property>
case:
package com.itheima.e_api;import java.util.List;import org.hibernate.Criteria;import org.hibernate.Query;import org.hibernate.Session;import org.hibernate.criterion.DetachedCriteria;import org.hibernate.criterion.Restrictions;import org.junit.Test;import com.itheima.domain.Customer;import com.itheima.utils.HibernateUtils;public class Demo {@Test//验证c3p0连接池public void fun1(){Session session = HibernateUtils.openSession();session.beginTransaction();//------------------------------------------------System.out.println(session);//------------------------------------------------session.getTransaction().commit();session.close(); // 游离状态}}
0 0
- Hibernate整合连接池
- hibernate整合C3P0连接池
- Hibernate整合C3P0实现连接池
- Hibernate整合C3P0实现连接池
- Hibernate整合C3P0实现连接池
- Hibernate整合C3P0实现连接池
- hibernate、spring、c3p0整合(连接池)
- Hibernate整合C3P0实现连接池
- Hibernate整合C3P0实现连接池
- Spring整合Hibernate 使用dbcp连接池
- spring+struts+hibernate 的整合,采用proxool连接池
- Spring整合Hibernate时使用proxool连接池
- Spring整合BoneCP+Hibernate配置数据连接池
- spring与hibernate整合配置文件含连接池
- spring+hibernate+c3p0整合链接池配置-连接无法释放问题(已经解决)
- Spring整合HIbernate时,三种数据库连接池的配置和比较
- spring+hibernate+c3p0整合链接池配置-连接无法释放问题(已经解决)
- spring+hibernate+c3p0整合链接池配置-连接无法释放问题(已经解决)
- FunDA(5)- Reactive Streams:Play with Iteratees
- tensorFlow 教程
- View的事件分发机制
- ml note
- 【J2EE】Cookie
- Hibernate整合连接池
- 17 消息队列2
- View基础知识
- .Net多线程编程—使用Visual Studio 2012进行调试
- 解决React Native中ListView控件在ios上不能滑动的问题
- 大端字节序和小端字节序
- java网络爬虫开发笔记(3)
- mysql同时更新多条记录的同一个字段
- java