【问题标题】:class not found exception for com.mysql.jdbc.Drivercom.mysql.jdbc.Driver 的类未找到异常
【发布时间】:2023-04-07 13:00:02
【问题描述】:

我知道这个问题有很多线程,但这些解决方案都没有解决我的问题。我已将必要的 .jar 文件添加到 WEB-INF-lib 文件夹中,但仍然出现错误。我尝试直接将 .jar 文件添加到构建路径中,但仍然出现相同的错误。谁能帮我解决这个问题!我已经在这个问题上玩了几天了,但无济于事。

这是我的代码:

<%@ page import = "java.sql.*" %><%@ page import = "java.io.*" %><%@ page import = "com.mysql.*" %><?xml version ="1.0" ?>
<tours>
<%
    Connection connection = null;
    Statement staement = null;
    ResultSet result = null;

try{
    Class.forName("com.mySQL.jdbc.Driver").newInstance();   
    connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/tours", "root", "root");
    out.println("connected to database");
}
catch(SQLException e){
    out.println("error connecting to database");
}

%>

【问题讨论】:

    标签: java mysql eclipse jdbc buildpath


    【解决方案1】:

    您的 MySQL 驱动程序类的包名错误。变化自

      com.mySQL.jdbc.Driver
    

     com.mysql.jdbc.Driver
    

    【讨论】:

    • 感谢您发现我的粗心大写!
    猜你喜欢
    • 2013-04-06
    • 1970-01-01
    • 1970-01-01
    • 2017-06-09
    • 2011-10-05
    • 2012-04-19
    • 1970-01-01
    相关资源
    最近更新 更多