数据库连接是成功的,打印出rs.next()为false,sql语句在sqlplus中能查到数据。有没人遇到这个问题,要怎么解决啊??Java code:
public List getVoteList(int pageNo, int pageSize) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
int currentNo1 = pageNo * pageSize;
int currentNo2 = (pageNo - 1) * pageSize;
String sql = "select * from (select rownum r,s.* from(select * from surveyinfo order by createtime)s "
+ "where rownum<="
+ currentNo1
+ ") where r>"
+ currentNo2
+ "";
List list = new ArrayList();
try {
conn = DbConn.getConnection();
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(sql);
System.out.println(rs.next());
System.out.print(sql);
while (rs.next()) {
SurveyForm survey = new SurveyForm();
survey.setQid(rs.getInt("qid"));
survey.setQuestion(rs.getString("question"));
survey.setUserid(rs.getInt("userid"));
survey.setCid(rs.getInt("cid"));
survey.setCreateTime(rs.getDate("createdate"));
survey.setIscheck(rs.getInt("ischeck"));
survey.setOption1(rs.getString("option1"));
survey.setOption2(rs.getString("option2"));
survey.setOption3(rs.getString("option3"));
survey.setOption4(rs.getString("option4"));
survey.setOption5(rs.getString("option5"));
survey.setOption6(rs.getString("option6"));
survey.setOption7(rs.getString("option7"));
survey.setOption8(rs.getString("option8"));
survey.setOption9(rs.getString("option9"));
survey.setOption10(rs.getString("option10"));
list.add(survey);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DbConn.close(conn);
DbConn.close(pstmt);
DbConn.close(rs);
}
return list;
}
public List getVoteList(int pageNo, int pageSize) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
int currentNo1 = pageNo * pageSize;
int currentNo2 = (pageNo - 1) * pageSize;
String sql = "select * from (select rownum r,s.* from(select * from surveyinfo order by createtime)s "
+ "where rownum<="
+ currentNo1
+ ") where r>"
+ currentNo2
+ "";
List list = new ArrayList();
try {
conn = DbConn.getConnection();
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(sql);
System.out.println(rs.next());
System.out.print(sql);
while (rs.next()) {
SurveyForm survey = new SurveyForm();
survey.setQid(rs.getInt("qid"));
survey.setQuestion(rs.getString("question"));
survey.setUserid(rs.getInt("userid"));
survey.setCid(rs.getInt("cid"));
survey.setCreateTime(rs.getDate("createdate"));
survey.setIscheck(rs.getInt("ischeck"));
survey.setOption1(rs.getString("option1"));
survey.setOption2(rs.getString("option2"));
survey.setOption3(rs.getString("option3"));
survey.setOption4(rs.getString("option4"));
survey.setOption5(rs.getString("option5"));
survey.setOption6(rs.getString("option6"));
survey.setOption7(rs.getString("option7"));
survey.setOption8(rs.getString("option8"));
survey.setOption9(rs.getString("option9"));
survey.setOption10(rs.getString("option10"));
list.add(survey);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DbConn.close(conn);
DbConn.close(pstmt);
DbConn.close(rs);
}
return list;
}
解决方案 »
- <ORA-00904: "PRP"."PAYREFDATE": 标识符无效问题,请各位高手帮忙看看。
- spring+hibernate
- 请教Javascript
- 怎样让java应用程序在没有java虚拟机的电脑上运用行
- 50分求解jsf简单问题
- web services 在Vector中传输多个javabean对象,如何解决?
- 23种设计模式--原型模式
- 请教一下tomcat5下配置struts问题!!!
- 想知道Struts中,是如何实现"view"部份的,请给个例子,谢谢
- JPA注解 能不能在项目部署时,向数据库表中插入一条数据呢?
- 酷狗
- 在标题里输入特殊字符会导致以标题为链接的列表的链接代码错误
要是Statement对象应该可以这样写
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();写多了一个sql,这里改一下。。
不知lz是否已解决了问题