| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 661 人关注过本帖
标题:[求助]JDBC滚动结果集问题!
只看楼主 加入收藏
心动音符
Rank: 1
等 级:禁止访问
威 望:1
帖 子:832
专家分:0
注 册:2005-9-15
收藏
 问题点数:0 回复次数:3 
[求助]JDBC滚动结果集问题!

我在JSP中写到:(代码片断)


Connection conn = cgclass.getConn();
Statement stmt = conn.createStatemen(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql = \"select distinct SELL_ORG_ID,SELLING_ORG_NAME,city,area_id from new_fmt_supplier order by city\";
ResultSet rs = stmt.executeQuery(sql);
pages=rs.getFetchSize()/20;



rs.absolute(row*20+1); 为什么这句话抛异常!(方法不支持,为什么不支持啊 我有设置滚动结果集啊)
for(int i=0;i<20;i++){
rs.next();
String SELL_ORG_ID = rs.getString(\"SELL_ORG_ID\").trim();
String SELL_ORG_NAME = rs.getString(\"SELLING_ORG_NAME\").trim();
String city = rs.getString(\"city\").trim();
String area_id = rs.getString(\"area_id\").trim();
something...
}


异常如下:
org.apache.jasper.JasperException: Sharenet.S331.ex.txt: Method not yet supported.
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
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.access$000(ApplicationFilterChain.java:98)
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:176)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:172)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:534)


[此贴子已经被作者于2007-8-7 13:11:42编辑过]

搜索更多相关主题的帖子: JDBC 滚动 结果 row 
2007-08-07 13:10
黄袖标
Rank: 4
等 级:贵宾
威 望:13
帖 子:676
专家分:0
注 册:2007-3-22
收藏
得分:0 
这个问题貌似有前辈问过了,可以查查以前的帖子

我胡汉三又回来啦!物是人非啊,只有静夜思大大还在。
2007-08-07 13:12
huluhulu88
Rank: 1
等 级:新手上路
帖 子:118
专家分:0
注 册:2007-5-19
收藏
得分:0 

看了下面一个示例可能对你有所帮助

conn.jsp
<%
String sDBDriver = "COM.ibm.db2.jdbc.app.DB2Driver";
String sConnStr = "jdbc:db2:faq";
Connection conn = null;
Statement stmt = null;
ResultSet rs=null;
try {
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e) {
out.print("faq(): " + e.getMessage());
}

try{
conn = DriverManager.getConnection(sConnStr,"wsdemo","wsdemo1");
stmt = conn.createStatement();
}catch(SQLException e){
out.print(e.toString());
}
%>

query.jsp

<%@ page language="java" import="java.sql.*" %>
<%@ page contentType="text/html; charset=gb2312" %>
<%@ include file="conn.jsp" %>
<%
.......
int pages=0;
int pagesize=10;
ResultSet result = null;
ResultSet rcount = null;

pages = new Integer(request.getParameter("pages")).intValue();

if (pages>0)
{

String sql=" state=´我不傻´";
int count=0;
try {
rcount = stmt.executeQuery("SELECT count(id) as id from user where "+sql);
catch(SQLException ex) {
out.print("aq.executeQuery: " + ex.getMessage());
}
if(rcount.next())
count = rcount.getInt("id");
rcount.close();

if (count>0)
{
sql="select * from user where "+sql;
try {
result = stmt.executeQuery(sql);
}
catch(SQLException ex) {
out.print("aq.executeQuery: " + ex.getMessage());
}

int i;
String name;
// result.first();
// result.absolute((pages-1)*pagesize);
// 此方法jdbc2.0支持。编译通过,但执行不过,不知是不是跟驱动有关,只好用下面的笨办法。
for(i=1;i<=(pages-1)*pagesize;i++)
result.next();
for(i=1;i<=pagesize;i++) {
if (result.next()) {
name=result.getString("name");
out.print(name);
}
result.close();
int n= (int)(count/pagesize);
if (n*pagesize<count) n++;
if (n>1)
{
for(i=1;i<=n;i++)
out.print("<a href=query.jsp?pages="+i+">"+i+" </a>");
}
}
}
%>


2007-08-07 14:58
无缘今生
Rank: 2
等 级:新手上路
威 望:3
帖 子:523
专家分:7
注 册:2007-6-25
收藏
得分:0 
楼上大哥,能不能解释一下红色部分啊?看不大明白啊!

时不再来!!!
2007-08-07 16:23
快速回复:[求助]JDBC滚动结果集问题!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.053533 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved