ITADN

Syntax Error with Statement.RETURN_GENERATED_KEYS

#594Opendwenking 创建于 2023-11-16
D
dwenkingcommented
In the provided test case, a CREATE TABLE SQL statement is executed using stmt.executeUpdate(createTableSql, Statement.RETURN_GENERATED_KEYS). This execution unexpectedly results in a syntax error: "syntax error at or near 'RETURNING'". This behavior is inconsistent with Postgres JDBC. ```java @Test public void test() { try (Connection con = DriverManager.getConnection("jdbc:pgsql://localhost:5432/test0", "user", "password")) { Statement stmt = con.createStatement(); String createTableSql = "CREATE TABLE table0_0(id INT PRIMARY KEY, value VARCHAR(5));"; stmt.executeUpdate(createTableSql, Statement.RETURN_GENERATED_KEYS); } catch (SQLException e) { e.printStackTrace(); // syntax error at or near "RETURNING" } } ```
0 条评论