exception - java.lang.ClassNotFoundException:com.mysql.jdbc.Driver -
i'm getting exception java.lang.classnotfoundexception
when trying run code,
my code
try { class.forname("com.mysql.jdbc.driver"); connection con=drivermanager.getconnection("jdbc:mysql://localhost:3306/simple", "root","root"); statement stmt=con.createstatement(); string query="select * cust"; resultset rs=stmt.executequery(query); while(rs.next()) { system.out.print(rs.getstring("cust_name") +" "); system.out.print(rs.getstring(2) +" "); system.out.print(rs.getstring(3) +" "); } rs.close(); stmt.close(); con.close(); } catch (classnotfoundexception e) { e.printstacktrace(); } catch (sqlexception e) { e.printstacktrace(); }
i'm getting error
java.lang.classnotfoundexception: com.mysql.jdbc.driver @ java.net.urlclassloader$1.run(urlclassloader.java:200) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:188) @ java.lang.classloader.loadclass(classloader.java:307) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:301) @ java.lang.classloader.loadclass(classloader.java:252) @ java.lang.classloader.loadclassinternal(classloader.java:320) @ java.lang.class.forname0(native method) @ java.lang.class.forname(class.java:169) @ simple.myprog.main(myprog.java:15)
what doing wrong?
problem not in code, don't have added driver project!!! have add *.jar
driver project...
try putting in lib directory, re-starting tomcat...
problem class.forname("com.mysql.jdbc.driver");
tries load driver, not getting it, reason getting java.lang.classnotfoundexception.
Comments
Post a Comment