关于连接池的
org.apache.jasper.JasperException: An exception occurred processing JSP page /chpt16/exa16_8.jsp at line 118: 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,大家帮我看下哪步有问题导致连接池连接失败的