日期:2014-05-17  浏览次数:20888 次

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 code

<?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>




------解决方案--------------------
1 尽信书不如无书.
2 调试时,可以先不要 try catch exception
3 确认你的 MySQL 密码是 123
4 RPWT
------解决方案--------------------
驱动版本不对,换个驱动版本
------解决方案--------------------
No suitable driver found for jdbc:mysql://localhost:3306
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.aiyiweb.com/java-web/317.html