使用JNDI进行Tomcat 5.5.17和MySQL连接池的配置
2006-10-10 22:26
471 查看
说明一下步骤:
一、修改server.xml文件
二、在%TOMCAT_HOME%/conf/Catalina/localhost下新建一个与你项目文件夹同名的xml文件
例如:我的项目名为testJNDI,那就创建一个testJNDI.xml的文件。内容为:
</Context>
三、修改%TOMCAT_HOME%/webapps/yourweb/WEB-INF下的web.xml文件
在</web-app>之前添加:
<resource-ref>
<description>mysql JNDI</description>
<res-ref-name>jdbc/testA</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>mysql JNDI</description>
<res-ref-name>jdbc/testA</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
PS.有多个就添加多个
一、修改server.xml文件
<Resource name="jdbc/testA" type="javax.sql.DataSource" auth="Container" password="123456" driverClassName="com.mysql.jdbc.Driver" maxIdle="2" maxWait="5000" username="root" url="jdbc:mysql://localhost:3306/testA" maxActive="4"/>
<Resource name="jdbc/testB" type="javax.sql.DataSource"
auth="Container" password="123456" driverClassName="com.mysql.jdbc.Driver" maxIdle="2" maxWait="5000" username="root" url="jdbc:mysql://localhost:3306/testB" maxActive="4"/>
PS.有多个JNDI就添加多个
二、在%TOMCAT_HOME%/conf/Catalina/localhost下新建一个与你项目文件夹同名的xml文件
例如:我的项目名为testJNDI,那就创建一个testJNDI.xml的文件。内容为:
<?xml version="1.0" encoding="UTF-8"?> <Context> <Resource name="jdbc/testA" type="javax.sql.DataSource"
auth="Container" password="123456" driverClassName="com.mysql.jdbc.Driver" maxIdle="2" maxWait="5000" username="root" url="jdbc:mysql://localhost:3306/testA" maxActive="4"/>
<Resource name="jdbc/testB" type="javax.sql.DataSource"
auth="Container" password="123456" driverClassName="com.mysql.jdbc.Driver" maxIdle="2" maxWait="5000" username="root" url="jdbc:mysql://localhost:3306/testB" maxActive="4"/>
</Context>
PS.其实Resource的内容和server.xml的一致。注意,要是这错误的话,会抛出错误
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
三、修改%TOMCAT_HOME%/webapps/yourweb/WEB-INF下的web.xml文件
在</web-app>之前添加:
<resource-ref>
<description>mysql JNDI</description>
<res-ref-name>jdbc/testA</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>mysql JNDI</description>
<res-ref-name>jdbc/testA</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
PS.有多个就添加多个
相关文章推荐
- Tomcat 6.0配置数据源(DBCP)和JNDI使用
- CentOS7 增加tomcat 启动,停止,使用systemctl进行配置
- 使用 JNDI 在 Tomcat 的 server.xml 中配置 Druid 数据源
- Tomcat中配置和使用JNDI
- JNDI学习总结(4)——Tomcat下使用Druid配置JNDI数据源
- Tomcat配置JMX并使用JvisualVm进行连接
- tomcat6中配置jndi及jndi在spring中的使用
- jndi使用druid,在tomcat中配置druid监控
- Tomcat 配置数据源(DBCP)和JNDI使用
- spring下tomcat使用weblogic配置的jndi数据源
- CentOS7 增加tomcat 启动,停止,使用systemctl进行配置
- Tomcat下配置JNDI数据库连接池并使用
- CentOS7 增加tomcat 启动,停止,使用systemctl进行配置
- Hibernate使用Tomcat配置的Mysql连接池
- [学习] 配置tomcat以便能使用HTTPS进行连接.
- 使用Eclipse进行Java Web项目开发注意事项-Tomcat配置
- Tomcat下配置JNDI数据库连接池并使用
- JNDI学习总结(二)——Tomcat下使用C3P0配置JNDI数据源
- JNDI学习总结(二)——Tomcat下使用C3P0配置JNDI数据源