我把資料酷的設定放在properties檔案中
所以不一定一定要用我的方式,使用者也可以直接寫死在XML中。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<properties resource="mybatis/db.properties">
</properties>
<environments default="developmentPOOLED"> <== 任意名稱但是要一致
<environment id="developmentPOOLED"> <== 任意名稱但是要一致
<transactionManager type="JDBC"/>
<dataSource type="POOLED"> <== 指定要使用連結池
<property name="driver" value="${driver}"/>
<property name="url" value="${testurl}"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
<property name="poolMaximumActiveConnections" value="10"/>
<property name="poolMaximumCheckoutTime" value="120000" />
<property name="poolMaximumIdleConnections" value="5"/>
<property name="poolTimeToWait" value="500" />
<property name="poolPingQuery" value="${pingquery}" />
<property name="poolPingEnabled" value="${pingenable}"/>
<property name="poolPingConnectionsNotUsedFor" value="${pingnotuse}" />
</dataSource>
</environment>
</environments>
</configuration>
-- db.properties
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://127.0.0.1:3306/mydb
testurl=jdbc:mysql://127.0.0.1:3306/mydb
username=user
password=pwd
pingquery=SELECT 1
pingenable=true
pingoldertime=0
pingnotuse=3600000
沒有留言:
張貼留言