why does executeUpdate return 1 even if no new row has been inserted?

前端 未结 2 1358
一生所求
一生所求 2021-01-21 08:02

here is my very simple table (Postgres):

CREATE TABLE IF NOT EXISTS PERFORMANCE.TEST
(
test text NOT NULL UNIQUE
);

if I try to insert a String

相关标签:
2条回答
  • 2021-01-21 08:12

    that was missing:

    conn.commit();
    

    (after the executeUpdate())

    actually a new row was inserted but the DB rolled back immediately.

    0 讨论(0)
  • 2021-01-21 08:20

    executeupdate is for a 'update table set column = value so on'. For insert just call execute of PreparedStatement.

    0 讨论(0)
提交回复
热议问题