JDBC连接Access数据库
报错信息,哪里出问题HTTP Status 500 - An exception occurred processing JSP page /Examples_26.jsp at line 32
type Exception report
message An exception occurred processing JSP page /Examples_26.jsp at line 32
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 /Examples_26.jsp at line 32
29: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
30: //step4:璁剧疆鏁版嵁搴撹?闂?繛鎺ュ瓧绗︿覆
31: String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb,*.accdb)};DBQ="+path;
32: Connection con = DriverManager.getConnection(url);
33: Statement st = con.createStatement();
34: String sql = "select * from userInfo";
35: ResultSet rs = st.executeQuery(sql);
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:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:912)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
org.apache.jsp.Examples_005f26_jsp._jspService(Examples_005f26_jsp.java:139)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6964)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7121)
sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3080)
sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
java.sql.DriverManager.getConnection(DriverManager.java:571)
java.sql.DriverManager.getConnection(DriverManager.java:233)
org.apache.jsp.Examples_005f26_jsp._jspService(Examples_005f26_jsp.java:96)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.30 logs.
Apache Tomcat/7.0.30