[英]SQL update Statement not changing record
我有一条sql更新语句,但是我不知道为什么它不更新我的记录,它什么都不做,语法有什么问题吗?
private static final String strUpdatePerson =
"UPDATE APP.PERSON " +
"SET FIRSTNAME = ?, " +
" LASTNAME = ?, " +
" ADDRESS = ?, " +
" PHONE = ?, " +
" EMAIL = ?, " +
" INFO = ? " +
"WHERE ID = ?";
这非常令人困惑,因为没有给出错误,它执行更新,但是数据库中的任何内容均未更改。
编辑:
这是正在执行的查询:
stmtUpdateExistingRecord = dbConnection.prepareStatement(strUpdateCustomer);
stmtUpdateExistingRecord.clearParameters();
stmtUpdateExistingRecord.setString(1, record.firstName.toUpperCase());
stmtUpdateExistingRecord.setString(2, record.lastName.toUpperCase());
stmtUpdateExistingRecord.setString(3, record.Address);
stmtUpdateExistingRecord.setString(4, record.phoneNumber);
stmtUpdateExistingRecord.setString(5, record.email);
stmtUpdateExistingRecord.setString(6, record.info);
stmtUpdateExistingRecord.setInt(7, record.getID());
stmtUpdateExistingRecord.executeUpdate();
您应该调用dbConnection.setAutoCommit(true);
在 executeUpdate()
或dbConnection.commit();
在 executeUpdate()
如果dbConnection.getAutoCommit()
返回true,则您遇到其他错误。 您确定它没有引发Exception
吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.