-1
String insert = "UPDATE PPN_WORKFLOW SET P1_F_Date = ?, SET P1_Completed = ?, SET C2_S_Date = ? WHERE ERF_No = ?";
            stmt = conn.prepareStatement(insert);
            stmt.setDate(1, date);
            stmt.setInt(2, 1);
            stmt.setDate(3, date);
            stmt.setInt(4, erf_no);
            stmt.executeUpdate();

我正在尝试更新声明,但收到此错误

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6956)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7113)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:3148)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedStatement.java:215)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(JdbcOdbcPreparedStatement.java:137)
at Mails.MailtoERF.check(MailtoERF.java:60)
at Mails.MailtoERF.main(MailtoERF.java:122)
4

4 回答 4

3

你不能那样设置。你需要改变语法。一次 SET 就足够了

UPDATE PPN_WORKFLOW SET P1_F_Date = ?, P1_Completed = ?..... where condition
于 2013-03-08T11:13:06.630 回答
3

每个列名都有一个SET,您只需要用逗号分隔列并且只使用SET一次,请参见此处的语法:

UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
于 2013-03-08T11:13:36.513 回答
2

您不需要SET每列:

MySQL 更新语法

UPDATE [LOW_PRIORITY] [IGNORE] table_reference
    SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
    [WHERE where_condition]
    [ORDER BY ...]
    [LIMIT row_count]

String insert = "UPDATE PPN_WORKFLOW SET P1_F_Date = ?, P1_Completed = ?,  
C2_S_Date = ? WHERE ERF_No = ?";
于 2013-03-08T11:13:00.353 回答
0

您的 Sql Update 语句语法错误。请放'SET' for each column in the query, you only do it at the first column

将其更改为

String insert = "UPDATE PPN_WORKFLOW SET P1_F_Date = ?, P1_Completed = ?, C2_S_Date = ? WHERE ERF_No = ?";
            stmt = conn.prepareStatement(insert);
            stmt.setDate(1, date);
            stmt.setInt(2, 1);
            stmt.setDate(3, date);
            stmt.setInt(4, erf_no);
            stmt.executeUpdate();

这是供您参考的语法

于 2013-03-08T11:21:11.633 回答