2 a945mvp A945MVP 于 2014.10.22 11:35 提问

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
freedamjustice   2014.10.22 16:27

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

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!