请帮一下, tomcat 5.0.25 配置连接池时总是报错,不能取得连接,以下是配置文件,测试文件和错误信息.

MiracleNo1 2004-08-13 03:55:15
TOMCAT_HOME\conf\Catalina\localhost\testdb.xml 如下:
<?xml version='1.0' encoding='utf-8'?>
<Context crossContext="true" displayName="testdb" docBase="testdb" path="/testdb" reloadable="true">
<Resource name="testdb" type="javax.sql.DataSource"/>
<ResourceParams name="testdb">
<parameter>
<name>url</name>
<value>jdbc:informix-sqli://162.162.162.162:8888/mydb:INFORMIXSERVER=test</value>
</parameter>
<parameter>
<name>password</name>
<value>test</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.informix.jdbc.IfxDriver</value>
</parameter>
<parameter>
<name>username</name>
<value>test</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
</ResourceParams>
</Context>

TOMCAT\webapps\testdb\index.jsp 如下:

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="javax.naming.*"%>
<%
Connection conn = null;
Context initCtx = new InitialContext();
if (initCtx == null)
throw new Exception("不能获取Context!");
Context ctx = (Context) initCtx.lookup("java:comp/env");
//获取连接池对象
Object obj = (Object) ctx.lookup("testdb");
if (obj == null)
throw new Exception("不能取得连接池对象");
//类型转换
javax.sql.DataSource ds = (javax.sql.DataSource) obj;

conn = ds.getConnection();

Statement stmt = conn.createStatement();
String strSql = "select * from t_operatordef;";
ResultSet rs = stmt.executeQuery(strSql);
while(rs.next()){
out.println(rs.getString(1));
}

rs.close();
stmt.close();
conn.close();

out.println("连接池测试成功");
%>

错误信息如下:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Cannot get a connection, pool exhausted, cause: Could not create a validated object
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.index_jsp._jspService(index_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
root cause
org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause: Could not create a validated object
org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:148)
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:518)
org.apache.jsp.index_jsp._jspService(index_jsp.java:62)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

...全文
110 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
www203 2004-08-13
  • 打赏
  • 举报
回复
资源耗尽?
不会是你数据库的最大连接数大少吧
bluesky1980 2004-08-13
  • 打赏
  • 举报
回复
一起学习
ITxiaopang 2004-08-13
  • 打赏
  • 举报
回复
支持一下!!!

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧