Exception while updating result set

From: Prasanth <dbadmin(at)pangburngroup(dot)com>
To: pgsql-jdbc(at)lists(dot)postgresql(dot)org
Subject: Exception while updating result set
Date: 2021-03-18 22:20:23
Message-ID: 472e572d-d1b9-63af-7a47-50c84dafe2ea@pangburngroup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

The following code generates an exception shown below. Commenting out the refreshRow() call would solve the issue. This exception happens only in driver versions 42.2.13 and above. Is this a bug in
the driver?

        ResultSet rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
        rs.next();
        rs.updateDate("start_date", Date.valueOf("2020-01-01"));
        rs.updateDate("end_date", Date.valueOf("2020-12-31"));
        rs.updateRow();
        rs.refreshRow();
        rs.updateDate("end_date", Date.valueOf("2020-12-30"));
        rs.updateRow(); // Exception occurs at this line.

Exception in thread "main" java.lang.IllegalArgumentException: Attempted to write to readonly tuple
    at org.postgresql.core.Tuple.set(Tuple.java:96)
    at org.postgresql.jdbc.PgResultSet.setRowBufferColumn(PgResultSet.java:1680)
    at org.postgresql.jdbc.PgResultSet.updateRowBuffer(PgResultSet.java:1733)
    at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1378)

Thanks,
Prasanth

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2021-03-22 11:06:45 [pgjdbc/pgjdbc] d6ef27: initial attempt at getting arm workflow working (#...
Previous Message Sehrope Sarkuni 2021-03-17 10:48:45 [pgjdbc/pgjdbc] 807ddb: test: Fix typo in assert message