首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 企业软件 > 行业软件 >

Tomcat6.0连接池的配备

2012-08-11 
Tomcat6.0连接池的配置首先,打开Tomcat的根目录\conf中的文件context.xml ?在context/context 中添加

Tomcat6.0连接池的配置

首先,打开Tomcat的根目录\conf中的文件context.xml ?在<context></context> 中添加这样一段配置:

?

<Resource

name = "jdbc/mysql"

auth="Container"

type="javax.sql.DataSource"

maxActive="100"

maxIdle="30"

maxWait="1000"

username="root"

password="dabatase's password"

driverClassName="com.mysql.jdbc.Driver"

url="jdbc:mysql://localhost:3306/test"

/>

?

1) name : 是指连接的名称。

2) auth : ?是指连接池的管理权限 Container是指容器管理。

3) type : 是指对象的类型。

4) maxActive : 是指连接池中连接数据库的最大数,当设为0时则表示没有限制。

5) maxIdle : 是指等待连接的最大数量,当设为0时则表示没有限制。

6) maxWait : 是指最大的等待秒数,当设为-1时表示无线等待。

?

?

在代码中通过上下文对象引用连接池:

?

Conext context = new InitialConext();

DataSource ds = (DataSource) context.lookup("java:comp/env/jdbc/mysql");

?

Connection conn = ds.getConnection();

?

之后该怎么进行就随意了。

?

其中高亮的部分为连接池的名称。

热点排行