我知道有很多关于这个问题的线索,但这些解决方案都没有解决我的问题。我已将必要的 .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");
}
%>
最佳答案
你的 MySQL 驱动类的包名有误。改变自
com.mySQL.jdbc.Driver
到
com.mysql.jdbc.Driver
关于java - 类未找到 com.mysql.jdbc.Driver 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24289387/