简体   繁体   中英

class not found exception for com.mysql.jdbc.Driver

I know there are many many threads on this problem but none of these solutions fix my issue. I have added the necessary .jar file to the WEB-INF-lib folder and i still get the error. I tried directly adding the .jar file to the build path, and i still get the same error. Can anyone help me out on this! I've been playing around with this issue for a couple days now to no avail.

Here's my code:

<%@ 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");
}

%>

You have wrong package name of MySQL driver class. Change from

  com.mySQL.jdbc.Driver

to

 com.mysql.jdbc.Driver

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM