Why do I see NotUpdatable when I invoke ResultSet.refreshRow()?

后端 未结 1 428
无人共我
无人共我 2021-01-21 23:32

When I invoke following rows:

Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet resultSet =         


        
相关标签:
1条回答
  • 2021-01-22 00:07

    When you are using, ResultSet.CONCUR_READ_ONLY, you are getting an exception, that

    com.mysql.jdbc.NotUpdatable: Result Set not updatable.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.\

    So, changing ResultSet.CONCUR_READ_ONLY to ResultSet.CONCUR_UPDATABLE, solved your problem. Correct?

    Now, as I understand, you don't want to do that. Am I right? If yes, then I think you are confusing ResultSet with Database,

    • ResultSet.CONCUR_READ_ONLY, means read only ResultSet, not Database, similarly
    • ResultSet.CONCUR_UPDATABLE, means updatable ResultSet, not Database.

    The method, resultSet.refreshRow(), suppose to update the resultSet, hence it rightly requires updatable ResultSet. I hope it's clear now.

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