update test.addressbook_table set phone=? and address=? where name=?");
              con.setAutoCommit(false);
              
              pStmt.setString(1,phone);
              pStmt.setString(2,address);
              pStmt.setString(3,name);
              int j=pStmt.executeUpdate();
              con.commit()
很奇怪,这里phone的值不是按照制定值更新,执行操作完总是为1.
(构造涵数 
 public AddressBookBean(String name,String phone,String address) {
    this.name=name;
    this.phone=phone;
    this.address=address;
    //this.id=id;
  }
)如果是插入 删除都是没有问题的,为什么update会餐出错误?

解决方案 »

  1.   

    那只能说 pStmt.setString(1,phone);这里的phone你就是赋值的1
      

  2.   

    你用debug运行.在这里打一个断点...pStmt.setString(1,phone);看看在未传入之前phone的值是什么?
      

  3.   


    update test.addressbook_table set phone=? , address=? where name=?"); 
      

  4.   

    未传入之前phone的值是  非1值 如118等
    执行完是1  .  
    插入没这问题,插入与构造的参数次序是一致的
    但是更新的次序有很大的变化
      

  5.   

    感谢yanliang_xt. 一个小的错误...
      

  6.   

    update的时候还用and干什么