Javatpoint Logo

How to load MYSQL driver ?

By: Dec12d*** On: Fri Jan 15 13:14:50 IST 2016     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank User
I've the following code but after running it there is a class not found exception of the driver class .. what should i do ?

try {
String name = request.getParameter("name");
String pass = request.getParameter("pass");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/dimple?zeroDateTimeBehavior=convertToNull", "root", "password");
PreparedStatement ps = con.prepareStatement("Insert Into data Values(? ,? )");
ps.setString(1, name);
ps.setString(2, pass);
int f = ps.executeUpdate();
if(f>0)
{
out.println("Successfuly inserted");
RequestDispatcher rd = request.getRequestDispatcher("index.html");
rd.forward(request, response);
}
else
out.println("Not inserted");

}
catch(Exception e)
{
out.println(e);
}



output:
Class NOT Found exception : com. mysql.jdbc.Driver
Up0Down