HTTP Status 500 - javax.servlet.ServletException: org.apache.tomcat.dbcp.dbcp.SQLNestedException
我的环境:eclipse+mysql+tomcatv7.0就是现在在搭建环境,然后测试一下,发现跑不起来。整体就两个文件:context.xml:<?xmlversion...
我的环境:eclipse+mysql+tomcat v7.0
就是现在在搭建环境,然后测试一下,发现跑不起来。
整体就两个文件:
context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context reloadable="true" crossContext="true">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/mydb"
username="cxm" password="19881208"
maxActive="100" maxIdle="30"
maxWait="10000" />
</Context>
index.jsp:
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"
import="java.sql.Connection,
java.sql.SQLException,
javax.sql.DataSource,
javax.naming.Context,
javax.naming.InitialContext,
javax.naming.NamingException"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
大家好
<%
Context ctx = new InitialContext();
String strLookup = "java:comp/env/jdbc/mydb";
DataSource ds =(DataSource) ctx.lookup(strLookup);
Connection con = ds.getConnection();
if (con != null){
out.print("success");
}else{
out.print("failure");
}
%>
</body>
</html>
完整错误信息:
HTTP Status 500 - javax.servlet.ServletException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Unknown database 'mydb')
求好心人解答,谢谢 展开
就是现在在搭建环境,然后测试一下,发现跑不起来。
整体就两个文件:
context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context reloadable="true" crossContext="true">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/mydb"
username="cxm" password="19881208"
maxActive="100" maxIdle="30"
maxWait="10000" />
</Context>
index.jsp:
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"
import="java.sql.Connection,
java.sql.SQLException,
javax.sql.DataSource,
javax.naming.Context,
javax.naming.InitialContext,
javax.naming.NamingException"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
大家好
<%
Context ctx = new InitialContext();
String strLookup = "java:comp/env/jdbc/mydb";
DataSource ds =(DataSource) ctx.lookup(strLookup);
Connection con = ds.getConnection();
if (con != null){
out.print("success");
}else{
out.print("failure");
}
%>
</body>
</html>
完整错误信息:
HTTP Status 500 - javax.servlet.ServletException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Unknown database 'mydb')
求好心人解答,谢谢 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询