当前位置: 技术问答>java相关
请大家帮忙看看错在哪里??~~~~thank u!
来源: 互联网 发布时间:2015-06-16
本文导语: 是sql server 数据库 con = DbConnectionManager.getConnection(); //取日期 String yestoday = request.getParameter("yestoday"); if(yestoday == null || yestoday.equals("")){ pstmt = con.prepareStatement("select getdate()-1"); ResultSet rs=ps...
是sql server 数据库
con = DbConnectionManager.getConnection();
//取日期
String yestoday = request.getParameter("yestoday");
if(yestoday == null || yestoday.equals("")){
pstmt = con.prepareStatement("select getdate()-1");
ResultSet rs=pstmt.executeQuery();
String yestodaya = rs.getString(1);
yestoday = yestodaya.substring(0,yestodaya.indexOf(' '));
pstmt.close();
}
//想取昨天的日期~~
错误提示:Invalid operation for the current cursor position.
各位大哥帮忙呀!
con = DbConnectionManager.getConnection();
//取日期
String yestoday = request.getParameter("yestoday");
if(yestoday == null || yestoday.equals("")){
pstmt = con.prepareStatement("select getdate()-1");
ResultSet rs=pstmt.executeQuery();
String yestodaya = rs.getString(1);
yestoday = yestodaya.substring(0,yestodaya.indexOf(' '));
pstmt.close();
}
//想取昨天的日期~~
错误提示:Invalid operation for the current cursor position.
各位大哥帮忙呀!
|
在rs.getString()之前加一句:
rs.next();
rs.next();
|
同上楼上的,你刚刚得到记录集,其游标在第一条记录以前,你必须先用
rs.next( );命令移到第一条记录,才可以操作!
rs.next( );命令移到第一条记录,才可以操作!