cannot create jdbc driver of class '' for connect url 'null'
tomcat6.0jdbc:mysql-connector-java-3.1.14-bin.jarD:\Java\Tomcat6.0\webapps\wuliuxinxi...
tomcat6.0 jdbc:mysql-connector-java-3.1.14-bin.jar
D:\Java\Tomcat 6.0\webapps\wuliuxinxi\META-INF\context.xml
<!-- The contents of this file will be loaded for each web
application -->
<Context reloadable="true" >
<Resource
auth="Container"
name="jdbc/DBPool"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
password="2009"
maxIdle="2"
maxWait="1000"
username="root"
url="jdbc:mysql://localhost:3306/yeyu?
autoReconnect=true&failOverReadOnly=false"
maxActive="10"/>
</Context>
D:\Java\Tomcat 6.0\webapps\wuliuxinxi\WEB-INF\web.xml
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>My Web Application</display-name>
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>test.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
<resource-ref>
<description>DB Connection pool</description>
<res-ref-name>jdbc/DBPool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>
D:\Java\Tomcat 6.0\webapps\wuliuxinxi\db.jsp
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="javax.naming.*"%>
<html>
<head>
<title></title>
</head>
<body>
<%
out.print("我的测试开始"+"<br/>");
DataSource ds = null;
try{
InitialContext ctx=new InitialContext();
ds=(DataSource)ctx.lookup("java:comp/env/jdbc/DBPool");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
String strSql = " select * from coil";
ResultSet rs = stmt.executeQuery(strSql);
while(rs.next()){
out.print(rs.getString(1)+"<br/>");
out.print(rs.getString(2)+"<br/>");
}
rs.close();
stmt.close();
conn.close();
out.print("我的测试结束");
}
catch(Exception ex){
out.print("出现意外,信息是:"+ex.getMessage());
ex.printStackTrace();
}
%>
</body>
</html>
出现意外,信息是:Cannot create JDBC driver of class '' for connect URL 'null'
为什么会这样?还要配置什么?配置错了? 展开
D:\Java\Tomcat 6.0\webapps\wuliuxinxi\META-INF\context.xml
<!-- The contents of this file will be loaded for each web
application -->
<Context reloadable="true" >
<Resource
auth="Container"
name="jdbc/DBPool"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
password="2009"
maxIdle="2"
maxWait="1000"
username="root"
url="jdbc:mysql://localhost:3306/yeyu?
autoReconnect=true&failOverReadOnly=false"
maxActive="10"/>
</Context>
D:\Java\Tomcat 6.0\webapps\wuliuxinxi\WEB-INF\web.xml
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>My Web Application</display-name>
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>test.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
<resource-ref>
<description>DB Connection pool</description>
<res-ref-name>jdbc/DBPool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>
D:\Java\Tomcat 6.0\webapps\wuliuxinxi\db.jsp
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="javax.naming.*"%>
<html>
<head>
<title></title>
</head>
<body>
<%
out.print("我的测试开始"+"<br/>");
DataSource ds = null;
try{
InitialContext ctx=new InitialContext();
ds=(DataSource)ctx.lookup("java:comp/env/jdbc/DBPool");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
String strSql = " select * from coil";
ResultSet rs = stmt.executeQuery(strSql);
while(rs.next()){
out.print(rs.getString(1)+"<br/>");
out.print(rs.getString(2)+"<br/>");
}
rs.close();
stmt.close();
conn.close();
out.print("我的测试结束");
}
catch(Exception ex){
out.print("出现意外,信息是:"+ex.getMessage());
ex.printStackTrace();
}
%>
</body>
</html>
出现意外,信息是:Cannot create JDBC driver of class '' for connect URL 'null'
为什么会这样?还要配置什么?配置错了? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询