我有一個(gè)程序可以查看用戶模型,如果它們不為空,則將值添加到準(zhǔn)備好的更新語句中,如下所示 PreparedStatement pst = conn.prepareStatement("UPDATE users SET name=?,email=?,pwd=?,avatar=?,sts=?,bio=?,country=? WHERE uuid=?"); if(this.name != null) pst.setString(1, this.name); if(this.email != null) pst.setString(2, this.email); if(this.password != null) pst.setString(3, this.password); if(this.avatar != null) pst.setString(4, this.avatar); if(this.status != null) pst.setString(5, this.status); if(this.bio != null) pst.setString(6, this.bio); if(this.country != null) pst.setString(7, this.country); pst.setString(6, this.id);我面臨的問題是準(zhǔn)備好的語句中不能有未定義的字段。我可以將不想更改的字段設(shè)置為等于什么?
添加回答
舉報(bào)
0/150
提交
取消