就这里有问题,明明是多个记录,但只执行一次
while(rs2.next()){
bookid = rs2.getString("bookid").trim();
m = rs2.getInt("num"); //定购数量
if(sales==1){
sql = "update bookinfo set nownum = nownum - "+ m +" where bookid ='"+bookid+"' ";
}else {
sql = "update bookinfo set nownum = nownum + "+ m +" where bookid ='"+bookid+"' ";
}
stmt.execute(sql); //好像这里有问题,跳出while循环了
}
while(rs2.next()){
bookid = rs2.getString("bookid").trim();
m = rs2.getInt("num"); //定购数量
if(sales==1){
sql = "update bookinfo set nownum = nownum - "+ m +" where bookid ='"+bookid+"' ";
}else {
sql = "update bookinfo set nownum = nownum + "+ m +" where bookid ='"+bookid+"' ";
}
stmt.execute(sql); //好像这里有问题,跳出while循环了
}
解决方案 »
- 新手上路,求大神指点,有关导出excel的问题
- 西安哪个java培训好?西安尚学堂,达内...怎么样?
- 各位老大们有没有写过能生成“quartz 时间表达式” 的js控件
- 请教自动对齐的算法
- 关于java web开发的技术问题?框架之类
- Could not synchronize database state with session
- Create CMP 2.0 Entity Bean 创建实体bean中没有field
- 有关泛型 谁能给我解释一下这小段代码
- 那里有Rational Rose 2003的下载和注册文件??
- JAVA怎么识别(输出)黑方块
- 请问hibernate数据库表关系的问题~
- 怎样使double类型的值只取小数点后两位??不使用字符串截取方法??如33.333333333333336取为0.33,而0.3取为0.30??在线等!
bookid = rs2.getString("bookid").trim();
m = rs2.getInt("num"); //定购数量
if(sales==1){
sql = "update bookinfo set nownum = nownum - "+ m +" where bookid ='"+bookid+"' ";
}else {
sql = "update bookinfo set nownum = nownum + "+ m +" where bookid ='"+bookid+"' ";
}
System.out.println(sql);//把sql打印出来有好处,在数据库里直接执行这条sql
stmt.execute(sql); //好像这里有问题,跳出while循环了
System.out.println("execute ok");//在这里打印一下
}
rs2.close();
return true;
}
catch (Exception e)
{
System.out.println(e.toString());//在这里打印错误
return false;
}
stmt.execute(sql); //是不是连续使用stmt会引起错误
我是这样定义的
DBConnectionManager dcm = new DBConnectionManager();
Connection conn = dcm.getConnection();
Statement stmt=conn.createStatement();
Statement stmt2=conn.createStatement();
{
System.out.println(e.toString());//在这里打印错误
return false;
}错误提示:
java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态
java.lang.NullPointerException