如果id
在mysql数据库中设置为auto_increment,那么我们应该如何声明占位符?
这是我的代码:
String sql="update bed set(bedname=?, bedprice=?, description=?, filename=?, path=? where id=?)";
PreparedStatement pst= con.prepareStatement(sql);
pst.setString(1, bdname);
pst.setString(2, bdprice);
pst.setString(3, desc);
pst.setString(4, fileName);
pst.setString(5, savePath);
pst.setInt(6, ) // what we have to put here ???
int i=pst.executeUpdate();
最佳答案
如果您将字段设置为自动递增,则无需为其指定任何准备好的语句。但如果您想更新特定行,那么您还必须提供 ID 号。
关于mysql - 在 mysql 数据库中使用 auto_increment 声明占位符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47942261/