连接池配置问题tomcat6+SqlServer2005+jdk1.6+MyEclipse7.5
我驱动sqljdbc.jar放到tomcat目录的lib下了,而且普通的连接方式可以连上,就是连接池连不上下面是我的test项目的META-INF下的test.xml
程序代码:<?xml version="1.0" encoding="UTF-8"?> <Context reloadable="true" crossContext="true"> <!-- Default set of monitored resources --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> <Resource name="jdbc/login" auth="Container" type="javax.sql.DataSource" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://localhost:1433;DataBaseName=login" username="sa" password="sadb" maxActive="100" maxIdle="30" maxWait="1000"/> </Context>接下来是test项目WEB-INF下的web.xml
程序代码:<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java. xmlns:xsi="http://www. xsi:schemaLocation="http://java. http://java.
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<resource-ref>
<description>login</description>
<res-ref-name>jdbc/login</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
最后是test项目的index.jsp
程序代码:<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="javax.naming.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>测试数据库连接池</title>
</head>
<body>
<%
Context context = new InitialContext();
Context envContext = (Context)context.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("jdbc/login");
Connection conn = ds.getConnection();
%>
<%= conn %>
<%
conn.close();
%>
</body>
</html>
MyEclipse下TOMCAT启动正常,但是运行结果却是:
程序代码:无法找到该网页
HTTP 400
最可能的原因是:
在地址中可能存在键入错误。
当您点击某个链接时,它可能已过期。
您可以尝试以下操作:
重新键入地址。
返回到上一页。
转到 并查找您想要的信息。
更多信息
为什么呢???连接了好几周了,却还是这样,恳请前辈们帮帮忙





