Spring(Bean)4 配置数据源、连接池

<!-- 配置数据源 Mysql
c3p0: 连接池.

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
注入值 基本信息(必须要有的)
<property name="user" value="root"></property>
<property name="password" value="1234"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/test"></property>
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>


<property name="initialPoolSize" value="5"></property>
<property name="maxPoolSize" value="10"></property>
</bean> 

-->

<!-- 引用外部化的配置文件

<context:property-placeholder location="classpath:db.properties"/> 
jdbc.password=1234
jdbc.url=jdbc:mysql://localhost:3306/test
jdbc.driver=com.mysql.jdbc.Driver
jdbc.initPoolSize=5
jdbc.maxPoolSize=10

-->


<!-- 配置数据源 使用外部化的配置文件 -->

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="${jdbc.user}"></property>
<property name="password" value="${jdbc.password}"></property>
<property name="jdbcUrl" value="${jdbc.url}"></property>
<property name="driverClass" value="${jdbc.driver}"></property>
<property name="initialPoolSize" value="${jdbc.initPoolSize}"></property>
<property name="maxPoolSize" value="${jdbc.maxPoolSize}"></property>

</bean>

 

<!-- 配置数据源
c3p0: 连接池. -->

<!-- <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> -->
<!-- <property name="user" value="USER_RZCLOUD"></property> -->
<!-- <property name="password" value="Richway1"></property> -->
<!-- <property name="jdbcUrl" value="jdbc:oracle:thin:@localhost/orcl"></property> -->
<!-- <property name="driverClass" value="oracle.jdbc.driver.OracleDriver"></property> -->
<!-- <property name="initialPoolSize" value="5"></property> -->
<!-- <property name="maxPoolSize" value="10"></property> -->
<!-- </bean> -->

 



<!-- 引入外部文件

<context:property-placeholder location="classpath:db.properties" />
jdbc.user = USER_RZCLOUD
jdbc.password = Richway1
jdbc.url = jdbc:oracle:thin:@localhost/orcl
jdbc.driver = oracle.jdbc.driver.OracleDriver
jdbc.initPoolSize=5
jdbc.maxPoolSize=10

-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="${jdbc.user}"></property>
<property name="password" value="${jdbc.password}"></property>
<property name="jdbcUrl" value="${jdbc.url}"></property>
<property name="driverClass" value="${jdbc.driver}"></property>
<property name="initialPoolSize" value="${jdbc.initPoolSize}"></property>
<property name="maxPoolSize" value="${jdbc.maxPoolSize}"></property>
</bean>

 

posted @ 2019-03-15 10:47  JiaXinYuan  阅读(259)  评论(0编辑  收藏  举报