You may be not copying your Mysql connector.jar inside WEB-INF/lib folder
MySql getConnection.Exception, Class com.mysql.jdbc.Driver Not found
-
08-10-2022 - |
Frage
I'm having the error with class not found exception whenever I try to call getConnection from ProductDataBean. Here's the code:
Product.java
ProductDataBean pdb = new ProductDataBean();
Connection connect = pdb.getConnection(); // ClassNotFoundException on this line)
ProductDataBean.java
package cart;
import java.io.*;
import java.sql.*;
import java.util.*;
public class ProductDataBean implements Serializable{
public static Connection getConnection() throws ClassNotFoundException, SQLException{
Class.forName("com.mysql.jdbc.Driver");
String connURL ="jdbc:mysql://localhost/onlinecart?user=root&password=teck1577130713";
Connection conn = DriverManager.getConnection(connURL);
return conn;
}
}
I will be thankful if u can help me solve this problem! :)
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow