当前位置: 首页 > 知识库问答 >
问题:

我面临java.sql.sqlException:没有找到适合JDBC:UCANAccess://C:/的驱动程序

陆子石
2023-03-14

请任何人帮助我在下面的错误,我面临着连接到ms access与JDK1.8.0_45。非常感谢任何帮助。:)

**Inside Servlet
inside get connection catch 
Exception : java.sql.SQLException: No suitable driver found for jdbc:ucanaccess://C:/ChintanDB/ChintanDB.accdb**
Apr 26, 2015 1:16:53 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [myservlettest] in context with path [/Test] threw exception
java.lang.NullPointerException
    at com.test.myservlettest.doPost(myservlettest.java:74)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

Inside Servlet
Apr 26, 2015 1:17:48 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [myservlettest] in context with path [/Test] threw exception
java.lang.NullPointerException
    at com.test.myservlettest.doPost(myservlettest.java:74)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

inside get connection catch 
Exception : java.sql.SQLException: No suitable driver found for jdbc:ucanaccess://C:/ChintanDB/ChintanDB.accdb

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 get connection catch ");
            System.out.println("Exception : " + e);
        }
        return con;
    }

}

myServletTest.java(Servlet类):

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 from 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 do post catch ");
            e.printStackTrace();
        }
        System.out.println("we are 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 + "! your login is successfull...";
        }
        else
        {
            msg="Hello " + un + "! your login is not successfull...";   
        }
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();
        out.println("<font size='6' color=red>" + msg + "</font>");
    }
}

共有1个答案

呼延才
2023-03-14

您没有注册驱动程序

Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");

检查正式入门指南

 类似资料:
  • 我已经检查了这个问题的所有消息,但它是一样的,它不起作用。我必须用java连接到sql服务器2008数据库,我已经添加了sqljdbc4.jar但什么也没有。 我做的不好,如果你还需要什么,请告诉我。 我收到这条消息: Java语言sql。SQLException:未找到适合jdbc的驱动程序:sqlserver://xxx.xxx.xxx.xxx:1433;databaseName=ccis;用

  • 我正在使用JDBC接收器连接器尝试Kafka和Postgres接收器。 例外: 水槽特性: 我已经设置了< code > plugin . path =/usr/share/Java/Kafka-connect-JDBC /usr/share/java/kafka-connect-jdbc我有以下文件: , , 和其他一些基本上与汇合物一起打包的罐子。 然后我下载了 postgres-jdbc 驱

  • 当我创建kafka jdbc源连接器(debezium连接器用于带有confluent-5.4.0的oracle)时,出现错误“没有找到适合jdbc: oracle: oci…”。 我的oracle版本是企业版发布11.2.0.4.0-64位生产,我尝试了不同的驱动程序jar,但得到了相同的异常。 我的jdk版本是: 我已经将 debezium-连接器-预言机添加到文件夹融合-5.4.0/shar

  • 试图连接到允许远程连接的免费mysql数据库主机,但我遇到了以下错误: 未找到适合jdbc的驱动程序:mysql://xx2-23-x1-2x1-172.compuxe-1.xmazonaws.com:3306 我使用下面的代码。 编辑 Stack Trace显示在下面:

  • 我正在尝试在我的本地tomcat服务器中部署一个基于Spring的Web应用程序。以下是我的申请详情: > 基于Spring的web应用程序(war) Tomcat 6服务器 Java 1.6 Oracle数据库 以下是按jdbc配置列出的: 配置仅适用于雄猫设置。 我还在我的 /lib 文件夹中添加了 ojdbc6.jar,ojdbc14.jar 我毫无问题地部署了我的war文件。但是当我的应用

  • null servet是一个简单的“Hello World”servlet,只是为了测试连接。