You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public void test () throws SQLException, ClassNotFoundException {
Class.forName("org.postgresql.Driver");
Connection connection = DriverManager.getConnection("jdbc:postgresql://192.168.0.125:5432/testdatabase", "postgres", "xxxxxxxxxxxxxxxxxxxxxxxx");
String sql = "SELECT * FROM accounting_periods where plan_id = 30756 order by start_date";
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(); // this is where the exception occurs.
connection.close();
}
public static void main(String args[]) {
try {
new RowSet().test();
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
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.updateRowBuffer(PgResultSet.java:1690)
at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1384)
at com.nqadmin.test.RowSet.test(RowSet.java:22)
at com.nqadmin.test.RowSet.main(RowSet.java:28)
The text was updated successfully, but these errors were encountered:
When updating a resultset the second time, after a refresh row causes an exception.
Driver Version: 42.2.11 and above
Java Version: 1.8.0.292
OS Version: CentOS 8
PostgreSQL Version: 12
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
public class RowSet {
}
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.updateRowBuffer(PgResultSet.java:1690)
at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1384)
at com.nqadmin.test.RowSet.test(RowSet.java:22)
at com.nqadmin.test.RowSet.main(RowSet.java:28)
The text was updated successfully, but these errors were encountered: