Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MYSQL error:com.mysql.jdbc.NotUpdatable

I am getting this error

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

I know this error is regarding the primary key but for all my tables I initially insert a primary key.So for this table also I have a primary key.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 if something is going wrong in 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    |                |
+----------------+---------------+------+-----+---------+----------------+
like image 494
Standin.Wolf Avatar asked Oct 01 '13 05:10

Standin.Wolf


1 Answers

You have to update the row immediately after you have fetched it (FOR UPDATE and rs.updateRow(),

OR

you have to write an UPDATE tablename set = where statement to update a row at any time

like image 50
logan Avatar answered Oct 05 '22 19:10

logan