I am facing java.sql.SQLException: No suitable driver found for jdbc:ucanaccess://C:/ -
could 1 please assist me on below error facing while connecting ms access jdk1.8.0_45. appreciated. :)
ide : eclipse luna ms access : 2010
as advised earlier in stack overflow have added below 5 jars in webcontent\web-inf\lib
ucanaccess-2.0.9.4.jar jackcess-2.0.8.jar hsqldb.jar commons-logging-1.1.1.jar commons-lang-2.6.jar
console log :
**inside servlet inside connection catch exception : java.sql.sqlexception: no suitable driver found jdbc:ucanaccess://c:/chintandb/chintandb.accdb** apr 26, 2015 1:16:53 pm org.apache.catalina.core.standardwrappervalve invoke severe: servlet.service() servlet [myservlettest] in context path [/test] threw exception java.lang.nullpointerexception @ com.test.myservlettest.dopost(myservlettest.java:74) @ javax.servlet.http.httpservlet.service(httpservlet.java:646) @ javax.servlet.http.httpservlet.service(httpservlet.java:727) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:303) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:241) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:220) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:122) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:504) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:170) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:103) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:950) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:116) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:421) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1074) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:611) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:316) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) @ java.lang.thread.run(unknown source) inside servlet apr 26, 2015 1:17:48 pm org.apache.catalina.core.standardwrappervalve invoke severe: servlet.service() servlet [myservlettest] in context path [/test] threw exception java.lang.nullpointerexception @ com.test.myservlettest.dopost(myservlettest.java:74) @ javax.servlet.http.httpservlet.service(httpservlet.java:646) @ javax.servlet.http.httpservlet.service(httpservlet.java:727) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:303) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:241) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:220) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:122) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:504) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:170) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:103) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:950) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:116) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:421) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1074) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:611) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:316) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) @ java.lang.thread.run(unknown source) inside connection catch exception : java.sql.sqlexception: no suitable driver found jdbc:ucanaccess://c:/chintandb/chintandb.accdb
chintandatabse.java :
package com.database; import java.sql.*; import java.util.logging.level; import java.util.logging.logger; import com.test.beans.*; public class chintandatabase { public connection getconnection() throws sqlexception { connection con = null; try { con = drivermanager.getconnection("jdbc:ucanaccess://c:/chintandb/chintandb.accdb"); } catch (exception e) { system.out.println("inside connection catch "); system.out.println("exception : " + e); } return con; } }
myservlettest.java (servlet class) :
public class myservlettest extends httpservlet { private static final long serialversionuid = 1l; public myservlettest() { super(); } public void dopost(httpservletrequest req, httpservletresponse res) throws ioexception { system.out.println("inside servlet"); chintandatabase cd = new chintandatabase(); connection con = null; string userid =""; string password = ""; try { con = cd.getconnection(); statement s = con.createstatement(); s.executequery("select soe_id,password user"); resultset rs = s.getresultset(); while ((rs != null) && (rs.next())) { userid = rs.getstring("soe_id"); password = rs.getstring("password"); } s.close(); con.close(); } catch (sqlexception e) { system.out.println("inside post catch "); e.printstacktrace(); } system.out.println("we in service method of servlet"); string un =req.getparameter("username") ; string pw =req.getparameter("userpass") ; string msg =""; if ((un.equals(userid) && pw.equals(password))) { msg="hello " + un + "! login successfull..."; } else { msg="hello " + un + "! login not successfull..."; } res.setcontenttype("text/html"); printwriter out = res.getwriter(); out.println("<font size='6' color=red>" + msg + "</font>"); } }
you not registering driver.
class.forname("net.ucanaccess.jdbc.ucanaccessdriver");
check offical getting started guide
Comments
Post a Comment