是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.
各位大哥帮忙呀!
在rs.getString()之前加一句:
rs.next();
同上楼上的,你刚刚得到记录集,其游标在第一条记录以前,你必须先用
rs.next( );命令移到第一条记录,才可以操作!