求助:使用ResultSet接收查询结果总是结果集无当前行

苦逼的小码农 苦逼的小码农 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
代码大概如下

String sql_1 = "select * from or_detail where orderId=? and productCode=?"
String str_1 = request.getParameter("orderId");
String str_2 = request.getParameter("productCode");
ResultSet rs_1 = (new JDBCutil()).execute(sql_1,str_1,str_2);
if(rs_1.next()){
double price = rs_1.getDouble("price");
double qty = rs_1.getDouble("qty");
}

//JDBCutil 的execute方法如下
public ResultSet execute(String sql ,String str_1,String st_2){
session = this.getSession();
ResuleSet rs = null;
try{
conn = session.connection();
pstat = conn.prepareStatement(sql);
pstat.setString(1,str_1);
pstat.setString(2,str_2);
rs_1 = pstat.executeQuery();
}catch(Exception e){
e.printStackTrace();
}
return rs_1;
}

我接收的结果 就是无法进入 if循环
就是 我的rs_1.next() 为 false
...全文
评论 8
收藏 已收藏
分享
返回顶部
苦逼的小码农
Web 开发 81,107 成员 341,720 内容