stmtUpdateExistingRecord

stmtUpdateExistingRecord

我有一条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吗?

10-08 19:34