2 m374018 m374018 于 2014.10.31 11:19 提问

JSP连接ACCESS数据库出错,tomcat

用的是JdbcOdbc,已配置School系统数据源,尝试了网上好多方法,都没有解决,上火。。
这是tomcat出错信息:
org.apache.jasper.JasperException: An exception occurred processing JSP page /index1.jsp at line 28

25:


26: <%
27: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
28: Connection conn=DriverManager.getConnection("jdbc:odbc:School");
29: Statement stat=conn.createStatement();
30: String sql="insert into T_STUDENT(STUNO,STUNAME,STUSEX) values ('4','老虎','男')";
31: int i=stat.executeUpdate(sql);

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:412)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause
javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Microsoft Access 驱动程序] 不能打开数据库 '(未知的)'。应用程序可能无法识别该数据库,或文件可能损坏。
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
org.apache.jsp.index1_jsp._jspService(index1_jsp.java:102)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause
java.sql.SQLException: [Microsoft][ODBC Microsoft Access 驱动程序] 不能打开数据库 '(未知的)'。应用程序可能无法识别该数据库,或文件可能损坏。
sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.apache.jsp.index1_jsp._jspService(index1_jsp.java:86)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

这是JSP源码:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:School");
Statement stat=conn.createStatement();
String sql="insert into T_STUDENT(STUNO,STUNAME,STUSEX) values ('4','老虎','男')";
int i=stat.executeUpdate(sql);
out.println("cheng gong+ "+i+" hang");
stat.close();
conn.close();

1个回答

qq_30651453
qq_30651453   2016.05.17 22:20

不知道啊,怎么办,我也行不到办法

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