一、
打开tomcat的控制台http://localhost:8888/admin
然后选择Resources的DataSources。在DataSourceActions里选择CreateNewDataSource。
然后配置是
JNDIName:jdbc/mysql
DataSourceURL:jdbc:mysql://localhost:3306/mysql
JDBCDriverClass:
UserName:root
Password:******
Max.ActiveConnections:4
Max.IdleConnections:2
Max.WaitforConnection:5000
ValidationQuery:
完成后“"save“"。记得要再上面的“"CommitChanges“"。不然所有设置就白费了
二、
用文本编辑器打开D:/tomcat5/conf/server.xml,找到结束标志,然后在之前加上如下语句:
<Context path="/myapps" docBase="d:/mywebmyapps" debug="0"
reloadable="true" >
<Resource name="jdbc/DBConnection"
auth="Container"
type="javax.sql.DataSource" />
<ResourceParams name="jdbc/DBConnection">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>3</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value>1234</value>
</parameter>
<!-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/forumdb?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>
打开tomcat的控制台http://localhost:8888/admin
然后选择Resources的DataSources。在DataSourceActions里选择CreateNewDataSource。
然后配置是
JNDIName:jdbc/mysql
DataSourceURL:jdbc:mysql://localhost:3306/mysql
JDBCDriverClass:
UserName:root
Password:******
Max.ActiveConnections:4
Max.IdleConnections:2
Max.WaitforConnection:5000
ValidationQuery:
完成后“"save“"。记得要再上面的“"CommitChanges“"。不然所有设置就白费了
二、
用文本编辑器打开D:/tomcat5/conf/server.xml,找到结束标志,然后在之前加上如下语句:
<Context path="/myapps" docBase="d:/mywebmyapps" debug="0"
reloadable="true" >
<Resource name="jdbc/DBConnection"
auth="Container"
type="javax.sql.DataSource" />
<ResourceParams name="jdbc/DBConnection">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>3</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value>1234</value>
</parameter>
<!-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/forumdb?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>