Pregunta

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

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top