Spring 整合 hibernate的 applicationContext.xml 数据源配置

来源:互联网 发布:迷你网页聊天室源码 编辑:程序博客网 时间:2024/05/21 17:46

Spring 整合 hibernate的 applicationContext.xml 数据源配置

发表于1年前(2012-11-10 23:59)   阅读(189) | 评论(0) 1人收藏此文章, 我要收藏
0
Spring 整合 hibernate的 applicationContext.xml 数据源配置

01<!-- 数据源配置 -->
02    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
03        destroy-method="close">
04        <property name="driverClass">
05            <value>com.mysql.jdbc.Driver</value>
06        </property>
07        <property name="jdbcUrl">
08            <value>jdbc:mysql://localhost:3306/dog</value>
09        </property>
10        <!-- 默认初始化获取3个连接  -->
11        <!-- 空闲连接检查时间 -->
12        <property name="idleConnectionTestPeriod">
13            <value>18000</value>
14        </property>
15        <!-- 最大空闲连接时间 3小时 -->
16        <property name="maxIdleTime">
17            <value>25000</value>
18        </property>
19        <!-- 检查获取的连接是否有效 -->
20        <property name="testConnectionOnCheckin">
21            <value>true</value>
22        </property>
23        <property name="testConnectionOnCheckout">
24            <value>true</value>
25        </property>
26        <!-- 测试语句 -->
27        <property name="preferredTestQuery">
28            <value>select 1</value>
29        </property>
30        <property name="properties">
31            <props>
32                <prop key="user">root</prop>
33                <prop key="password">123456</prop>
34                <prop key="c3p0.acquire_increment">5</prop>
35                <prop key="c3p0.idle_test_period">18000</prop>
36 
37                <!--  连接空闲超时时间  -->
38                <prop key="c3p0.timeout">20000</prop>
39                <prop key="c3p0.max_size">40</prop>
40                <prop key="c3p0.max_statements">100</prop>
41                <prop key="c3p0.min_size">10</prop>
42            </props>
43        </property>
44    </bean>
0 0