java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver doesn't work anymore in java. How to fix this? -
it worked 2 days ago. doesn't. i'm 100% sure coding correct. way used connect database. couldn't find answer yet problem. please give me answer i'm beginner java language. (using jdk 7u72)
public void set() { try { class.forname("sun.jdbc.odbc.jdbcodbcdriver"); string su=new string("jdbc:odbc:moviesurf"); //this database con=drivermanager.getconnection(su,"",""); st=con.createstatement(); } catch(exception e2){system.out.println(e2);} }
this stack trace
java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver @ java.net.urlclassloader$1.run(unknown source) @ java.net.urlclassloader$1.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ sun.misc.launcher$appclassloader.loadclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ java.lang.class.forname0(native method) @ java.lang.class.forname(unknown source) @ a.set(jptest7.java:410) @ a.actionperformed(jptest7.java:560) @ javax.swing.abstractbutton.fireactionperformed(unknown source) @ javax.swing.abstractbutton$handler.actionperformed(unknown source) @ javax.swing.defaultbuttonmodel.fireactionperformed(unknown source) @ javax.swing.defaultbuttonmodel.setpressed(unknown source) @ javax.swing.plaf.basic.basicbuttonlistener.mousereleased(unknown source) @ java.awt.component.processmouseevent(unknown source) @ javax.swing.jcomponent.processmouseevent(unknown source) @ java.awt.component.processevent(unknown source) @ java.awt.container.processevent(unknown source) @ java.awt.component.dispatcheventimpl(unknown source) @ java.awt.container.dispatcheventimpl(unknown source) @ java.awt.component.dispatchevent(unknown source) @ java.awt.lightweightdispatcher.retargetmouseevent(unknown source) @ java.awt.lightweightdispatcher.processmouseevent(unknown source) @ java.awt.lightweightdispatcher.dispatchevent(unknown source) @ java.awt.container.dispatcheventimpl(unknown source) @ java.awt.window.dispatcheventimpl(unknown source) @ java.awt.component.dispatchevent(unknown source) @ java.awt.eventqueue.dispatcheventimpl(unknown source) @ java.awt.eventqueue.access$400(unknown source) @ java.awt.eventqueue$3.run(unknown source) @ java.awt.eventqueue$3.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.security.protectiondomain$1.dointersectionprivilege(unknown source) @ java.security.protectiondomain$1.dointersectionprivilege(unknown source) @ java.awt.eventqueue$4.run(unknown source) @ java.awt.eventqueue$4.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.security.protectiondomain$1.dointersectionprivilege(unknown source) @ java.awt.eventqueue.dispatchevent(unknown source) @ java.awt.eventdispatchthread.pumponeeventforfilters(unknown source) @ java.awt.eventdispatchthread.pumpeventsforfilter(unknown source) @ java.awt.eventdispatchthread.pumpeventsforhierarchy(unknown source) @ java.awt.eventdispatchthread.pumpevents(unknown source) @ java.awt.eventdispatchthread.pumpevents(unknown source) @ java.awt.eventdispatchthread.run(unknown source) connection failed select password users username='ashane' error: java.lang.nullpointerexception
based on comments, system running on java 8 jre. odbc bridge has been removed this, , future versions. need find native jdbc driver database want connect to, , put on classpath.
java -classpath "[/path/to/your/driver.jar];." [yourclassname]
alternatively, explicitly use jdk 7 runtime, i'd recommend against this. you've uncovered compatibility problem, , it's better solve try work around it.
Comments
Post a Comment