Spring使用C3P0,从db.properties文件中读取信息,连接数据库

来源:互联网 发布:淘宝运营wlpeixun 编辑:程序博客网 时间:2024/06/03 17:29
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;">spring配置信息</span>
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"><?xml version="1.0" encoding="UTF-8"?></span>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans        http://www.springframework.org/schema/beans/spring-beans.xsd        http://www.springframework.org/schema/aop        http://www.springframework.org/schema/aop/spring-aop.xsd        http://www.springframework.org/schema/context        http://www.springframework.org/schema/context/spring-context.xsd"><context:property-placeholder location="classpath:db.properties" /><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="driverClass" value="${jdbc.driverClass}"></property><property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property><property name="initialPoolSize" value="${jdbc.initPoolSize}"></property><property name="maxPoolSize" value="${jdbc.maxPoolSize}"></property></bean></beans>
db.properties文件信息
jdbc.user=rootjdbc.password=rootjdbc.driverClass=com.mysql.jdbc.Driverjdbc.jdbcUrl=jdbc:mysql://localhost:3306/springjdbc.initPoolSize=5jdbc.maxPoolSize=10


0 0