Вопрос

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! :)

Это было полезно?

Решение

You may be not copying your Mysql connector.jar inside WEB-INF/lib folder

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top