对只转发结果集的⽆效操作:last--这样的错误package dao;
import java.util.ArrayList;
import dateba.DBOperException;
import dateba.DBSource;
import java.sql.*;
import struts.form.TestForm;
import vo.urVO;
import tool.Page;
public class urDAO {
String sql = null;
//控制分页的属性
共享英文
int page = 1;
int maxPage = 1;
//最⼤记录数量
private int maxRecordNumber=0;
public int getMaxPage() {
return maxPage;
}
public int getPage() {
return page;
}
public void tMaxPage(int maxPage) {
this.maxPage = maxPage;
}
public void tPage(int page) {
this.page = page;国立大学
}
白细胞低吃什么好/**
* @return maxRecordNumber
*/
public int getMaxRecordNumber() {
return maxRecordNumber;
}
/
**
* @param maxRecordNumber 要设置的 maxRecordNumber
*/
public void tMaxRecordNumber(int maxRecordNumber) {
this.maxRecordNumber = maxRecordNumber;
}
/**
*
* @param testForm FORM对象
* @param requestpage 被请求的页
* @param pageNum 每页的数量(显⽰)
* @return
* @throws DBOperException
*/
public ArrayList lectUSERBASICINFO(TestForm testForm,int requestpage,int pageNum) throws DBOperException{
//⼴告信息列表
ArrayList adlist = new ArrayList();
// 需要的数据库对象
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
//查询条件
sql = "lect urid,urpassword,phone,email from urbasicinfo where x=?";
// 得到连接
conn = Connection();
//pstmt = conn.prepareStatement(sql);修改之前的语句
pstmt = conn.prepareStatement(sql,
网件精灵
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);//修改过的语句
形容香味的词语pstmt.tString(Sex());
System.out.Sex());
//执⾏查询
rs = uteQuery();
//得到最⼤的数量
int pageNumber = pageNum;
boolean last = rs.last();//将cursor移到最后
if(last){
int rowNumber = rs.getRow();//获取符合的数据条数
//设置列表中的显⽰数量
maxRecordNumber = rowNumber;
maxPage = rowNumber/pageNumber;
if(rowNumber % pageNumber > 0){
maxPage++;
}
}
//如果输⼊的页⼤于最⼤的页⾯,则选择最⼤的页⾯
if(requestpage >= maxPage){
page = maxPage;
}el{
this.page = requestpage;
}
//把查询到的历史信息组合成历史信息对象,然后添加到全部历史对象中 if(page > 1 && last){
rs.absolute(pageNumber * (page - 1));
}el if(page == 1 && last){
rs.beforeFirst(); //将cursor移到初始状态
}
//把查询到的历史信息组合成历史信息对象,然后添加到全部历史对象中 int currentPosition = 0;
//把查找到的全部⼴告基本信息对象放到集合对象中
()&& currentPosition < pageNumber && last){
//创建⼀个VO对象到底放while外⾯还是放while⾥⾯
urVO urvo= new urVO();洋葱平安
urvo.String("email"));
urvo.String("phone"));
urvo.String("urid"));
urvo.String("urpassword"));
/
/把属性加⼊列表
adlist.add(urvo);
currentPosition ++ ;
}
} catch (SQLException ex) {
try {
} catch (SQLException e) {
e.printStackTrace();
}
ex.printStackTrace();
throw new DBOperException("数据库更新失败!"); } finally {
try {
// 关闭连接
rs.clo();
pstmt.clo();
conn.clo();
} catch (SQLException ex1) {
ex1.printStackTrace();
}
}
//返回得到⼴告显⽰信息的列表
return adlist;
}
}
java.sql.SQLException: 对只转发结果集的⽆效操作: last
at oracle.jdbc.driver.DatabaError.throwSqlException(DatabaError.java:111)
at oracle.jdbc.driver.DatabaError.throwSqlException(DatabaError.java:145)
at oracle.jdbc.driver.BaResultSet.last(BaResultSet.java:81)
at at.dbcp.dbcp.DelegatingResultSet.last(DelegatingResultSet.java:328)
马来西亚特产
人类的起源与进化at dao.urDAO.lectUSERBASICINFO(urDAO.java:86)
at struts.ute(TestAction.java:54)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.rvlet.http.HttpServlet.rvice(HttpServlet.java:709)
at javax.rvlet.http.HttpServlet.rvice(HttpServlet.java:802)
at org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at tool.EncodeFilter.doFilter(EncodeFilter.java:42)
at org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.StandardContextValve.invoke(StandardContextValve.java:178)
at org.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.tor.CoyoteAdapter.rvice(CoyoteAdapter.java:148)
at http11.Http11Processor.process(Http11Processor.java:856)
at http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at at.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
2008-1-22 20:07:28 org.apache.struts.action.RequestProcessor processException
警告: Unhandled Exception thrown: class dateba.DBOperException
2008-1-22 20:07:28 org.ApplicationContext log
信息: null
产⽣错误代码⾏:
pstmt = conn.prepareStatement(sql);
boolean last = rs.last();
将pstmt = conn.prepareStatement(sql);
改为:pstmt = conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet.TYPE_SCROLL_INSENSITIVE 双向滚动,但不及时更新,就是如果数据库⾥的数据修改过,并不在ResultSet中反应出来。 ResultSet.TYPE_SCROLL_SENSITIVE 双向滚动,并及时跟踪数据库⾥的更新,以便更改ResultSet中的数据。
ResultSet.CONCUR_READ_ONLY 只读取ResultSet 。
ResultSet.CONCUR_UPDATABLE ⽤ResultSet更新数据库 。