******************************************
第一种SIMPLE
1、sql-map-config.xml
....
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property value="${driver}" name="JDBC.Driver"/>
<property value="${url}" name="JDBC.ConnectionURL"/>
<property value="${username}" name="JDBC.Username"/>
<property value="${password}" name="JDBC.Password"/>
</dataSource>
</transactionManager>
....
2、database.properties
....
driver=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@localhost:1521:mydb
username=ibatis
password=ibatis
....
注意:编译、运行程序时记得要加(ibatis/WEB-INF/lib)classes12.jar包
******************************************
第二种JNDI
1、sql-map-config.xml
....
<transactionManager type="JDBC">
<dataSource type="JNDI">
<property name="DataSource" value="java:comp/env/jdbc/jpetstore" />
</dataSource>
</transactionManager>
....
2、server.xml
....
<Context path="/ibatis" docBase="ibatis" reloadable="true" crossContext="true">
<Resource name="jdbc/jpetstore"
auth="Container"
type="javax.sql.DataSource"
maxActive="10" maxIdle="5" maxWait="100"
username="ibatis" password="ibatis"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:mydb"/>
</Context>
....
3、web.xml
....
<resource-ref>
<description>JPetStore DataSource</description>
<res-ref-name>jdbc/jpetstore</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
....
注意:编译、运行程序时记得要加(ibatis/WEB-INF/lib)classes12.jar包,并且从oracle根目录下oracle/ora92/jdbc/lib/classes12.jar(数据库驱动类)放置于tomcat根目录lib下
******************************************
第三种DBCP
1、sql-map-config.xml
....
<transactionManager type="JDBC">
<dataSource type="DBCP">
<property value="${driver}" name="JDBC.Driver"/>
<property value="${url}" name="JDBC.ConnectionURL"/>
<property value="${username}" name="JDBC.Username"/>
<property value="${password}" name="JDBC.Password"/>
<property name="Pool.MaximumActiveConnections" value="30"/>
<property name="Pool.MaximumIdleConnections" value="15"/>
<property name="Pool.MaximumWait" value="60000"/>
<property name="Pool.ValidationQuery" value="select * from dual"/>
<property name="Pool.LogAbandoned" value="true"/>
<property name="Pool.RemoveAbandoned" value="true"/>
<property name="Pool.RemoveAbandonedTimeout" value="150"/>
</dataSource>
</transactionManager>
....
2、database.properties
....
driver=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@localhost:1521:mydb
username=ibatis
password=ibatis
....
注意:从oracle根目录下oracle/ora92/jdbc/lib/classes12.jar(数据库驱动类)放置于tomcat根目录lib下;并且把commons-dbcp-1.2.2.jar,commons-pool-1.3.jar放到tomcat根目录lib下。