| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 682 人关注过本帖
标题:关于连接池的
只看楼主 加入收藏
tottibuffon
Rank: 2
等 级:论坛游民
帖 子:105
专家分:20
注 册:2009-6-5
结帖率:83.87%
收藏
 问题点数:0 回复次数:2 
关于连接池的
org.apache.jasper.JasperException: An exception occurred processing JSP page /chpt16/exa16_8.jsp at line 11

8: response.setContentType("text/html;charset=gbk");
9: Context initCtx = new InitialContext(); //这里四句是连接池的关键语句
10: Context envCtx = (Context) initCtx.lookup("java:comp/env");
11: DataSource ds = (DataSource)envCtx.lookup("jdbc/studadmin");
12: Connection conn = ds.getConnection();
13: String studentId=request.getParameter("studentId").trim();
14: String studentName=new String(request.getParameter("studentName").trim().getBytes("iso-8859-1"));
我试了好几个JSP网页,总是在11: DataSource ds = (DataSource)envCtx.lookup("jdbc/studadmin");上出错
下面是配置文件我的conf目录下的chpt16.xml和web-inf目录下的web.xml。
程序代码:
<Context path="/chpt16" docBase="E:\Tomcat 6.0\webapps\Webexa\chpt16" reloadable="true">
<Resource name="jdbc/studadmin" auth="Container" type="javax.sql.DataSource" username="sa" password="sadb" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" maxIdleTime="8000" maxIdle="2" minPoolSize="100"  maxPoolSize="300" maxWait="5000" maxActive="44" acquireIncrement="5" auth="Container" url="jdbc:sqlserver://localhost:1433;DatabaseName=studadmin"/>
</Context><?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java. xmlns:xsi="http://www. xsi:schemaLocation="http://java. web-app_2_4.xsd"
    version="2.4">
    <resource-ref>
    <description>postgreSQL Datasource example</description>
    <res-ref-name>jdbc/studadmin</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
     <welcome-file-list>
        <welcome-file>exa16_1.jsp</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

我用的是sql sever 2005还有tomcat6.0,大家帮我看下哪步有问题导致连接池连接失败的
搜索更多相关主题的帖子: occurred java 
2010-05-06 09:05
tottibuffon
Rank: 2
等 级:论坛游民
帖 子:105
专家分:20
注 册:2009-6-5
收藏
得分:0 
太黏了,从新发下连接池数据源配置文件的代码
//chpt16.xml
<Context path="/chpt16" docBase="E:\Tomcat 6.0\webapps\Webexa\chpt16" reloadable="true">
<Resource name="jdbc/studadmin" auth="Container" type="javax.sql.DataSource" username="sa" password="sadb" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" maxIdleTime="8000" maxIdle="2" minPoolSize="100"  maxPoolSize="300" maxWait="5000" maxActive="44" acquireIncrement="5" auth="Container" url="jdbc:sqlserver://localhost:1433;DatabaseName=studadmin"/>
</Context>
//web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.
    xmlns:xsi="http://www.
    xsi:schemaLocation="http://java. web-app_2_4.xsd"
    version="2.4">
    <resource-ref>
    <description>postgreSQL Datasource example</description>
    <res-ref-name>jdbc/studadmin</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
     <welcome-file-list>
        <welcome-file>exa16_1.jsp</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>
2010-05-06 09:08
tottibuffon
Rank: 2
等 级:论坛游民
帖 子:105
专家分:20
注 册:2009-6-5
收藏
得分:0 
谁帮我解决下呢?
2010-05-06 15:48
快速回复:关于连接池的
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023232 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved