jdbc.properties文件:
DzswB2B.druid.alias=dbccfw
DzswB2B.druid.driver-url=jdbc:oracle:thin:@10.1.94.252:1521:dzsw
DzswB2B.druid.username=ccfw
DzswB2B.druid.password=ccfw
druid.driver-class=oracle.jdbc.driver.OracleDriver
#DzswB2B.druid.driver-url=jdbc:mysql://localhost:3306/test
#DzswB2B.druid.username=root
#DzswB2B.druid.password=root
#druid.driver-class=com.mysql.jdbc.Driver
druid.initialSize=2
druid.maxActive=5
druid.minIdle=1
#获取连接等待超时的时间,单位是毫秒
druid.maxWait=60000
#间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
druid.timeBetweenEvictionRunsMillis=60000
#一个连接在池中最小生存的时间,单位是毫秒
druid.minEvictableIdleTimeMillis=300000
在Spring的配置文件中配置数据源:(Spring-application.xml)
<!-- 数据库连接配置文件路径及名称 -->
<context:property-placeholder location="classpath:config/jdbc.properties" /><!-- 配置数据源 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<!-- 基本属性 url、user、password -->
<property name="url"><value>${DzswB2B.druid.driver-url}</value></property>
<property name="username"><value>${DzswB2B.druid.username}</value></property>
<property name="password"><value>${DzswB2B.druid.password}</value></property>
<property name="driverClassName"><value>${druid.driver-class}</value></property>
<!--
java -cp druid-0.2.23.jar com.alibaba.druid.filter.config.ConfigTools you_password
<property name="connectionProperties" value="config.decrypt=true" /> -->
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize"><value>${druid.initialSize}</value></property>
<property name="minIdle"><value>${druid.minIdle}</value></property>
<property name="maxActive"><value>${druid.maxActive}</value></property>
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait"><value>${druid.maxWait}</value></property>
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis">
<value>${druid.timeBetweenEvictionRunsMillis}</value>
</property>
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis">
<value>${druid.minEvictableIdleTimeMillis}</value>
</property>
<property name="validationQuery" value="SELECT 1 FROM DUAL" />
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<!-- 配置监控统计拦截的filters -->
<property name="filters" value="wall,config,slf4j" />
</bean>
.........
配置JDBC模板/配置Hibernate/配置Mybatis
(后续。。。。)