A945MVP
2014-10-22 03:35
采纳率: 0%
浏览 2.2k

JSP连接office Access2013数据库的问题

<%@ page language="java" import="java.sql.*" pageEncoding="GB2312"%>


Access


连接Access数据库

<%
String driverClass="sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:driver={Microsoft Access Driver(*.mdb)};DBQ="+path+":/db_database2013.mdb";
String username = "";
String password = "";
Class.forName(driverClass);

Connection conn=DriverManager.getConnection(url, username, password);
Statement stmt=conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from tb_user");
while(rs.next()){
out.println("
用户名:"+rs.getString(2)+" 密码:"+rs.getString(3));
}
rs.close();
stmt.close();
conn.close();
%>

却出现了如下的错误:
type Exception report

message An exception occurred processing JSP page /Access.jsp at line 16

description The server encountered an internal error that prevented it from fulfilling this request.

exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /Access.jsp at line 16

13: System.out.println("URL:"+url);
14: String username = "";
15: String password = "";
16: Class.forName(driverClass);

17: Connection conn=DriverManager.getConnection(url, username, password);
18: Statement stmt=conn.createStatement();
19: ResultSet rs = stmt.executeQuery("select * from tb_user");

Stacktrace:
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:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause
javax.servlet.ServletException: java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:905)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:834)
org.apache.jsp.Access_jsp._jspService(Access_jsp.java:111)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause
java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1293)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1145)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:125)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:62)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:260)
org.apache.jsp.Access_jsp._jspService(Access_jsp.java:85)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

note The full stack trace of the root cause is available in the Apache Tomcat/8.0.14 logs.
实在无奈,求大神相助!!

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • freedamjustice 2014-10-22 08:27

    报错不是说得很清楚,找不到类么。自己排查一下。

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题