JSP - Microsoft ODBC - Microsoft Access驱动程序找不到文件'(未知)'

时间:2015-12-27 13:59:32

标签: java sql-server jsp ms-access jdbc

我是JSP的新手。所以我想创建一个登录网站,但我坚持使用sql异常。 Annyone知道如何解决这个问题?我使用的所有程序都是32位,我已经将Ms Access数据库添加到我的用户数据源。

这是错误信息:

5: <%
6:  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
7:  Connection con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="+application.getRealPath("WEB-INF/db.accdb"));
8:  Statement st = con.createStatement(1004,1008);
9: 
10: %>

堆栈跟踪:

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
root cause

javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:916)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:845)
    org.apache.jsp.khema.doLogin_jsp._jspService(doLogin_jsp.java:145)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
root cause

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.
    sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
    sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
    sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3073)
    sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
    sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
    java.sql.DriverManager.getConnection(DriverManager.java:582)
    java.sql.DriverManager.getConnection(DriverManager.java:207)
    org.apache.jsp.khema.doLogin_jsp._jspService(doLogin_jsp.java:72)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

1 个答案:

答案 0 :(得分:0)

首先,请确保指定了DB文件的正确路径,执行此操作后,请执行以下步骤。  从控制面板搜索管理工具,然后在添加Microsoft Access Drivers(*mdb,*accdb)之后搜索数据源(ODBC)。