Tomcat jndi 数据库配置 连接池配置
2006-09-19 11:28
736 查看
在Tomcat 5.5/conf/Catalina/localhost/xxxxx.xml(xxxxx.xml为你自己的web的配置xml文件) 中添加resource
<Resource name="MYSQL"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
password="********"
maxIdle="2"
maxWait="5000"
username="root"
url="jdbc:mysql://localhost:3306/jnestore"
maxActive="10"/>
以上是tomcat 5.5版本的配置,5.5版本只有这样陪才有效果,以前的版本可以按照paramter的方法添加;
Resource 一定要包含在<Context ......> </Context> 之间
在你的web的路近下,WEB-INF中找到web.xml,添加资源映射
<resource-ref>
<description>connection</description>
<res-ref-name>MYSQL</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
把mysql的jdbc驱动.jar包放到tomcat的common/lib下去,也可以放到WEB-INF/lib下,
重新启动tomcat.
就可以用Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:comp/env/MYSQL");
Connection con = ds.getConnection(); 来连接数据库连接池
<Resource name="MYSQL"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
password="********"
maxIdle="2"
maxWait="5000"
username="root"
url="jdbc:mysql://localhost:3306/jnestore"
maxActive="10"/>
以上是tomcat 5.5版本的配置,5.5版本只有这样陪才有效果,以前的版本可以按照paramter的方法添加;
Resource 一定要包含在<Context ......> </Context> 之间
在你的web的路近下,WEB-INF中找到web.xml,添加资源映射
<resource-ref>
<description>connection</description>
<res-ref-name>MYSQL</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
把mysql的jdbc驱动.jar包放到tomcat的common/lib下去,也可以放到WEB-INF/lib下,
重新启动tomcat.
就可以用Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:comp/env/MYSQL");
Connection con = ds.getConnection(); 来连接数据库连接池
相关文章推荐
- Tomcat jndi 数据库配置 连接池配置
- tomcat5.0与tomcat5.5的数据库连接池jndi配置区别
- TOMCAT中数据库连接池的配置(JNDI方式)
- JNDI配置Tomcat的数据库连接池
- Tomcat jndi 数据库配置 连接池配置
- Tomcat jndi 数据库配置 连接池配置
- 连接池配置c3p0、dbcp、tomcat jdbc pool 及常用数据库的driverClass和驱动包
- 项目中用Tomcat自带连接池的配置数据库
- 使用JNDI配置Tomcat数据源[提高访问数据库效率]
- tomcat 6.0.20 连接池配置 SQL server 2000数据库
- 使用Tomcat-5.5.20配置数据库连接池详细介绍
- Eclipse+TomCat+MySQL配置数据库连接池
- 使用Tomcat-5.5.20配置数据库连接池详细介绍
- Spring+Tomcat的JNDI数据源连接池简单配置
- tomcat配置数据库连接池,提示classNotFoundException
- Tomcat-5.5.20下配置MySQL-5.0.27的数据库连接池(一)
- Java数据库连接-JNDI方式- 配置Tomcat6.0 连接池 配置相关
- 在tomcat下context.xml中配置各种数据库连接池
- 怎样配置Tomcat6.0的数据库连接池详解
- 配置Tomcat的数据库连接池