Tomcat创建MySQL数据库错误代码如下,谁能告诉我出什么问题了?
我的servlet程序的代码应该没问题,可以通过eclipse的编译,web.xml的配置也是按书上一模一样来的。
Tomcat版本6.0.20;MySQL版本5.0.22
出错代码如下:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306
CreateDBServlet.doGet(CreateDBServlet.java:46)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306
java.sql.DriverManager.getConnection(DriverManager.java:602)
java.sql.DriverManager.getConnection(DriverManager.java:185)
CreateDBServlet.doGet(CreateDBServlet.java:30)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
web.xml代码:
<?xml version="1.0" encoding="ISO-8859-1"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <servlet> <servlet-name>CreateDBServlet</servlet-name> <servlet-class>CreateDBServlet</servlet-class> <init-param> <param-name>driverClass</param-name> <param-value>com.mysql.jdbc.Driver</param-value> </init-param> <init-param> <param-name>url</param-name> <param-value>jdbc:mysql://localhost:3306</param-value> </init-param> <init-param> <param-name>user</param-name> <param-value>root</param-value> </init-param> <init-param> <param-name>password</param-name> <param-value>123</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>CreateDBServlet</servlet-name> <url-pattern>/createdb</url-pattern> </servlet-mapping> </web-app>