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个回答

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐