向各位高手请教jsp连接数据库的问题

weiny2000 2003-09-09 09:39:04
以下是代码:
-------------<%@ page contentType="text/html; charset=GB2312" %>
<%@ page import="java.sql.*" %>
<%@ page language="java" %>
<HTML>
<HEAD>
<TITLE>逆序取得数据</TITLE>
</HEAD>
<BODY>
<CENTER>
<FONT SIZE = 5 COLOR = blue>
逆序取得数据
</FONT>
</CENTER>
<BR>
<HR>
<BR>
<CENTER>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //载入驱动程序类别
Connection con = DriverManager.getConnection("jdbc:odbc:BookDB"); //建立数据库链接
//建立Statement对象, 并设置建立之ResultSet对象光标可前后移动
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt.executeQuery("SELECT * FROM Book"); //建立ResultSet(结果集)对象, 并执行SQL语句
rs.afterLast(); //将记录指标移至最后一笔
%>
<TABLE bgcolor=pink>
<TR bgcolor=silver>
<TD><B>书籍编号</B></TD><TD><B>书 名</B></TD><TD><B>作 者</B></TD>
</TR>
<%
//利用while循环将数据表中的记录列出
while (rs.previous())
{
%>
<TR bgcolor=#ffffff>
<TD><B><%= rs.getString("BookID") %></B></TD>
<TD><B><%= rs.getString("Title") %></B></TD>
<TD><B><%= rs.getString("Author") %></B></TD>
</TR>
<%
}
rs.close(); //关闭ResultSet对象
stmt.close(); //关闭Statement
con.close(); //关闭Connection对象
%>
</TABLE>
</CENTER>
</BODY>
</HTML>
------------------

表(Book)的结构很简单:
------------------
书籍编号 书 名 作 者
A0001 JSP时尚编程百例 网冠科技
A0002 ASP时尚编程百例 网冠科技
A0003 Java Script时尚编程百例 网冠科技
A0004 VB Script时尚编程百例 网冠科技
A0005 VB时尚编程百例 网冠科技
A0006 VC时尚编程百例 网冠科技
A0007 PB时尚编程百例 网冠科技
I0001 oracle时尚编程百例 修改
-----------------------------------------

我用的是JBuilder9+Access2000,运行后tomcat提示:
----------------
Apache Tomcat/4.0.6 - HTTP Status 500 - Internal Server Error

--------------------------------------------------------------------------------

type Exception report

message Internal Server Error

description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access 驱动程序] 系统不支持所选择的排序。
root cause

java.sql.SQLException: [Microsoft][ODBC Microsoft Access 驱动程序] 系统不支持所选择的排序。
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3065)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253)
at sun.jdbc.odbc.JdbcOdbcResultSet.calculateRowCount(JdbcOdbcResultSet.java:6209)
at sun.jdbc.odbc.JdbcOdbcResultSet.initialize(JdbcOdbcResultSet.java:150)
at sun.jdbc.odbc.JdbcOdbcStatement.getResultSet(JdbcOdbcStatement.java:424)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:254)
at org.apache.jsp.Previous$jsp._jspService(Previous$jsp.java:73)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:536)



--------------------------------------------------------------------------------
能帮我看看什么原因吗?谢谢回答!^_^

...全文
11 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
yaray 2003-09-09
驱动程序不支持你的所谓的"逆序取得数据"!!!
回复
pqds 2003-09-09
你用的是JdbcOdbc的桥
所选数据库不支持所选择逆排序。
rs.previous
换成rs.next就行

SELECT * FROM Book你的SQL是这样,逆徐有什么区别
如果十分重要用order by desc来逆徐排列

回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2003-09-09 09:39
社区公告
暂无公告