tomcat配置连接池
Tomcat5.0.28,jdk1.5,windowsXP,mysql5.0
主要依据Tomcat的帮助文档:
http://127.0.0.1:8080/tomcat-docs/jndi-datasource-examples-howto.html
1:创建数据库,用户名以及密码
mysql> GRANT ALL PRIVILEGES ON *.* TO javauser@localhost
-> IDENTIFIED BY 'javadude ' WITH GRANT OPTION;
mysql> create database javatest;
mysql> use javatest;
mysql> create table testdata (
-> id int not null auto_increment primary key,
-> foo varchar(25),
-> bar int);
2:添加数据
mysql> insert into testdata values(null, 'hello ', 12345);
Query OK, 1 row affected (0.00 sec)
mysql> select * from testdata;
+----+-------+-------+
| ID | FOO | BAR |
+----+-------+-------+
| 1 | hello | 12345 |
+----+-------+-------+
1 row in set (0.00 sec)
mysql>
3:配置server.xml文档,即将以下文件插入到server.xml的 <host> </host> 标记之间
<!--Context path= "/DBTest " docBase= "DBTest "-----此处tomcat的文档是有错误的(反正我配置不对)应该是以下配置,其中ss代表你的WEB程序名称-->
<Context path= "/ss " docBase= "ss " debug= "5 " reloadable= "true ">
debug= "5 " reloadable= "true " crossContext= "true ">
<Logger className= "org.apache.catalina.logger.FileLogger "
prefix= "localhost_DBTest_log. " suffix= ".txt "
timestamp= "true "/>
<Resource name= "jdbc/TestDB "
auth= "Container "
type= "javax.sql.DataSource "/>
<ResourceParams name= "jdbc/TestDB ">
<parameter>
<name> factory </name>
<value> org.apache.commons.dbcp.BasicDataSourceFactory </value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
&nbs