首先dbcp依賴幾個(gè)包
commons-collections
commons-pool
commons-dbcp
和mysql的驅(qū)動(dòng)包:mysql-connector-java
將以上四個(gè)包拷貝到tomcat安裝路徑下的commons/lib/下面
然后在tomcat安裝路徑下的conf下找到context.xml
加入如下文本:
<Resource name="jdbc/test" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="******" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test"/>
然后在自己的所建立的服務(wù)下的web.xml中加入:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
以上實(shí)例參考了apache的官方教程:http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
DHCP的一些資料:http://commons.apache.org/dbcp/configuration.html
還好國(guó)內(nèi)暫時(shí)可以訪問(wèn)apache的網(wǎng)站啊,myeclipse相比就要郁悶很多了。
commons-collections
commons-pool
commons-dbcp
和mysql的驅(qū)動(dòng)包:mysql-connector-java
將以上四個(gè)包拷貝到tomcat安裝路徑下的commons/lib/下面
然后在tomcat安裝路徑下的conf下找到context.xml
加入如下文本:
<Resource name="jdbc/test" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="******" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test"/>
然后在自己的所建立的服務(wù)下的web.xml中加入:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
以上實(shí)例參考了apache的官方教程:http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
DHCP的一些資料:http://commons.apache.org/dbcp/configuration.html
還好國(guó)內(nèi)暫時(shí)可以訪問(wèn)apache的網(wǎng)站啊,myeclipse相比就要郁悶很多了。