sql语句有问题,运行下来没问题,但好像pstmt.executeUpdate();不执行
public void UpOperator(operator operator){ //修改操作员信息
try{
conn = DBConn.getConnection();
String sql="update operator set opName=?,opTName=?,opPass=?,sex=?,opPhone=?,remak=? where opId=?";
pstmt =conn.prepareStatement(sql);
pstmt.setString(1, operator.getOpName());
pstmt.setString(2, operator.getOpTName());
pstmt.setString(3, operator.getOpPass());
pstmt.setString(4, operator.getSex());
pstmt.setInt(5, operator.getOpPhone());
pstmt.setString(6, operator.getRemak());
pstmt.setInt(7,operator.getOpId());
//operator.getOpName()这些测试过都已经是修改以后的数值了
int a= pstmt.executeUpdate();
if(a>0){
JOptionPane.showMessageDialog(null, "修改成功!");
}else{
JOptionPane.showMessageDialog(null, "修改失败!");
}
}catch(Exception e){
e.printStackTrace();
}
}
myeclipse没有报错
try{
conn = DBConn.getConnection();
String sql="update operator set opName=?,opTName=?,opPass=?,sex=?,opPhone=?,remak=? where opId=?";
pstmt =conn.prepareStatement(sql);
pstmt.setString(1, operator.getOpName());
pstmt.setString(2, operator.getOpTName());
pstmt.setString(3, operator.getOpPass());
pstmt.setString(4, operator.getSex());
pstmt.setInt(5, operator.getOpPhone());
pstmt.setString(6, operator.getRemak());
pstmt.setInt(7,operator.getOpId());
//operator.getOpName()这些测试过都已经是修改以后的数值了
int a= pstmt.executeUpdate();
if(a>0){
JOptionPane.showMessageDialog(null, "修改成功!");
}else{
JOptionPane.showMessageDialog(null, "修改失败!");
}
}catch(Exception e){
e.printStackTrace();
}
}
myeclipse没有报错
...全文
相关推荐
如何获得PreparedStatement最终执行的sql语句
NULL 博文链接:https://huiminchen.iteye.com/blog/1097332
Java使用Statement接口执行SQL语句操作实例分析
主要介绍了Java使用Statement接口执行SQL语句操作,结合实例形式详细分析了Java使用Statement接口针对mysql数据库进行连接与执行SQL语句增删改查等相关操作技巧与注意事项,需要的朋友可以参考下
java代码实现的sql语句效果
NULL 博文链接:https://lkf009.iteye.com/blog/1670754
SQL_执行语句(查询和修改)
SQL_执行语句(查询和修改),SQL_执行语句(查询和修改)
java通用executeUpdate类
注释很详细,大家自己看吧。适合初学者。 可以跟简化到只需要传入一个object对象。不断完善中....


Web 开发
