11月15日

今天对只修改记录中的某几个字段的数据有了了解,

String sql="update rkpc set idnum=?,sex=?,mz=?,shoujiao=? where name=?";
preparedStatement=conn.prepareStatement(sql);
preparedStatement.setString(5, ac.getName());

preparedStatement.setString(1, ac.getIdnum());
preparedStatement.setString(2, ac.getSex());
preparedStatement.setString(3, ac.getMz());
preparedStatement.setString(4, ac.getShoujiao());

列如通过name来进行位置确定对需要的字段进行修改,setString()中的数字的次序代表问号的次序。

原文地址:https://www.cnblogs.com/buyaoya-pingdao/p/14038029.html