I am making a web-app using GlassFish. In this webapp I need to be able to communicate with a MySQL Database. I downloaded the mysql-connector jar file and I added it in my build path. Still, when I try to connect to it I get this error: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
This is my code for connecting to the database:
public void connect(){
try {
Class.forName(dbClass);
connect = DriverManager.getConnection(dbUrl, "root", "333333");
statement = connect.createStatement();
System.out.println("Connected to Database");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I also attached a screenshot so you can see that the jar is added to the buildpath:

Any help is appreciated. Thanks
The jdbc driver
jaris surely not exported to the server. Go to theproblemsview inEclipseand you should see a warning that thejaris not exported. Right-click and select quick fix and then press OK to export it.