Javatpoint Logo

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

By: bvinit*** On: Sun Nov 06 16:20:40 IST 2016     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank User
<%@ page import="java.sql.*" import="java.sql.Driver.*"%>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/vinita","root","root");
String un=request.getParameter("t1");
String pw=request.getParameter("t2");
String q="select password from studentlogin where username=?";
PreparedStatement st=con.prepareStatement(q);
st.setString(1,un);
ResultSet rs=st.executeQuery(q);
rs.next();
if(un.equals(rs.getInt(1)))
{
out.println("welcome"+un);
}
else
{
out.println("invalid credentials");
}
con.close();
}
catch(Exception e){
out.println(e);
}
%>
I have set the classpath correctly and i have loaded mysql-connector.jar and i have set the classpath as C:\Program Files\Java\jre1.8.0_91\lib\ext\mysql-connector.jar;
Up0Down

 
Please add MySql JDBC driver to libary.Image Created0Down

By: [email protected] On: Tue Nov 15 10:47:15 IST 2016 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No