使用 ResultSet rs = ps.executeQuery();
答案:1 悬赏:20 手机版
解决时间 2021-03-30 22:56
- 提问者网友:皆是孤独
- 2021-03-30 18:15
使用 ResultSet rs = ps.executeQuery();
最佳答案
- 五星知识达人网友:廢物販賣機
- 2021-03-30 19:47
用下面的代码测试一下咯:public Category querybyid(int id){
Category cate=null;
try {
ps = cn.prepareStatement("select * from _category where id=?");
ps.setString(1,"id");
ResultSet rs = ps.executeQuery(); System.out.println("是否有数据:" + rs.newxt()); while(rs.next()){
cate=new Category();
cate.setId(rs.getInt(id));
cate.setName(rs.getString("name"));
cate.setDescription(rs.getString("description"));
}
} catch (Exception ex) {
ex.printStackTrace();
}
Category cate=null;
try {
ps = cn.prepareStatement("select * from _category where id=?");
ps.setString(1,"id");
ResultSet rs = ps.executeQuery(); System.out.println("是否有数据:" + rs.newxt()); while(rs.next()){
cate=new Category();
cate.setId(rs.getInt(id));
cate.setName(rs.getString("name"));
cate.setDescription(rs.getString("description"));
}
} catch (Exception ex) {
ex.printStackTrace();
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯