MYSQL error: com.mysql.jdbc.NotUpdatable

I get this error

javax.servlet.ServletException: com.mysql.jdbc.NotUpdatable: Result Install not updatable.

I know this error applies to the primary key, but for all my tables, I initially insert the primary key. Therefore, there is also a primary key for this table. I am posting part of my code.

Statement st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); ResultSet rs=st.executeQuery("Select * from test3 order by rand() limit 5"); List arrlist = new ArrayList(); while(rs.next()){ String xa =rs.getString("display"); if(xa.equals("1")){ arrlist.add(rs.getString("question_text")); } rs.updateString("display", "0"); rs.updateRow(); 

Just tell me there is something wrong with this code.please help. This is my database.

 +----------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | index_question | varchar(45) | YES | | NULL | | | question_no | varchar(10) | YES | | NULL | | | question_text | varchar(1000) | YES | | NULL | | | file_name | varchar(128) | YES | | NULL | | | attachment | mediumblob | YES | | NULL | | | display | varchar(10) | YES | | NULL | | +----------------+---------------+------+-----+---------+----------------+ 
+6
source share
2 answers

You should update the line immediately after receiving it (FOR UPDATE and rs.updateRow (),

OR

you need to write the UPDATE command tablename set = where to update the row at any time

+1
source

The request cannot use functions. Try removing "rand ()" from the SQL query string. See the JDBC 2.1 API Specification, Section 5.6 for more information.

0
source

Source: https://habr.com/ru/post/954991/


All Articles