Message-ID: From: "BbIKTOP (@BbIKTOP)" To: "pgjdbc/pgjdbc" Date: Fri, 17 Jan 2025 13:33:25 +0000 Subject: Re: [pgjdbc/pgjdbc] issue #3482: When using java.sql.Timestamp for update, an exception thrown In-Reply-To: References: List-Id: X-GitHub-Author-Login: BbIKTOP X-GitHub-Comment-Id: 2598379164 X-GitHub-Comment-Type: issue_comment X-GitHub-Edited-At: 2025-01-17T13:34:35Z X-GitHub-Issue: 3482 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3482#issuecomment-2598379164 Content-Type: text/plain; charset=utf-8 Well, workaround wit explicit bindings works fine in both cases: ``` private static final String MERGE_QUERY = """ merge into test as dst using (select ? as "id", ? as "ts", ? as amount) src on dst."id"=? when matched then update set "ts"=?, amount=? when not matched then insert ("id", "ts", "amount") values (?, ?, ?) """; @Test public void test() throws SQLException { try (Connection conn = dataSource.getConnection()) { log.info("Driver version {}", conn.getMetaData().getDriverVersion()); PreparedStatement ps = conn.prepareStatement(MERGE_QUERY); Integer id = 1; Timestamp ts = Timestamp.valueOf(LocalDateTime.now()); Integer amount = 123; ps.setObject(1, id); ps.setObject(2, ts); ps.setObject(3, amount); ps.setObject(4, id); ps.setObject(5, ts); ps.setObject(6, amount); ps.setObject(7, id); ps.setObject(8, ts); ps.setObject(9, amount); ps.executeUpdate(); } catch (Exception e) { log.error(e.getMessage(), e); } } ```