spring hibernate c3p0 mysql 配置
来源:互联网 发布:网络清洁器 编辑:程序博客网 时间:2024/05/21 17:32
c3p0 c3p0-0.9.1.2.jar
jdbc.properties
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8
jdbc.user=****
jdbc.password=****
jdbc.initialPoolSize=1
jdbc.minPoolSize=1
jdbc.maxPoolSize=10
spring配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- 引入参数配置文件 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
<!-- 配置数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass">
<value>${jdbc.driverClass}</value>
</property>
<property name="jdbcUrl">
<value>${jdbc.url}</value>
</property>
<property name="user">
<value>${jdbc.user}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property name="initialPoolSize">
<value>${jdbc.initialPoolSize}</value>
</property>
<property name="minPoolSize">
<value>${jdbc.minPoolSize}</value>
</property>
<property name="maxPoolSize">
<value>${jdbc.maxPoolSize}</value>
</property>
</bean>
<!-- spring Hibernate SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.jdbc.fetch_size">80</prop>
<prop key="hibernate.jdbc.batch_size">35</prop>
</props>
</property>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/pojos/</value>
</list>
</property>
</bean>
<!-- 事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 事务属性(新功能)
propagation="REQUIRED"(默认)事务传播行为(没有事务就传,有事务就用原来的)
isolation="DEFAULT" (默认)事务隔离级别
-->
<tx:advice id="mytx">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" isolation="DEFAULT"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" propagation="SUPPORTS" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 织入 -->
<aop:config>
<aop:advisor advice-ref="mytx" pointcut="execution(* com.server.*.*(..))"/>
</aop:config>
</beans>
文章来源于:http://blog.csdn.net/zhaoweitco/article/details/5657671
- spring hibernate c3p0 mysql 配置
- spring + hibernate+ C3P0+MYSQL 配置
- spring hibernate c3p0 mysql 配置
- Spring 结合 Hibernate 配置 C3P0
- Spring 结合 Hibernate 配置 C3P0
- Spring 结合 Hibernate 配置 C3P0
- Spring 结合 Hibernate 配置 C3P0
- hibernate mysql c3p0 详细配置
- Hibernate c3p0 Mysql 配置注意
- Spring - hibernate配置类方法配置c3p0
- 【非Web工程】Spring + C3P0 + Hibernate + Mysql
- Spring+Hibernate用 c3p0配置数据库连接池
- spring+hibernate的c3p0 连接池配置
- Spring 结合Hibernate 配置 C3P0 连接池
- C3P0数据库连接池配置【配合spring+hibernate】
- 在spring中通过hibernate配置C3P0
- Spring结合Hibernate配置C3P0数据源
- Mysql配置Spring数据源c3p0与dbcp
- c++开发过程中遇到的问题及解决方案
- 第二十六天【java虐我千百遍,我待java如初恋】
- 使用 yii 实现 REST 风格接口
- Erlang实现的简易HTTP服务器
- Android listView
- spring hibernate c3p0 mysql 配置
- 用户为什么离开你?
- 用STL实现堆容器
- 哈希表入门题目总结(HDU 1280、1425、2027、3833、1496、2648 POJ 1200)
- XDU Problem 1255 - 数列游戏
- Git 常用指令详解
- Hibernate的generator属性
- 编程中犯的错误
- Hype Cycle (技术成熟度曲线)