sto ottenendo questo erroreerrore MYSQL: com.mysql.jdbc.NotUpdatable
javax.servlet.ServletException: com.mysql.jdbc.NotUpdatable: Result Set not updatable.
So che questo errore è per quanto riguarda la chiave primaria, ma per tutti i miei tavoli inizialmente ho inserire una key.So primaria per questa tabella inoltre ho una chiave primaria. Sto postando parte del mio codice.
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();
Dimmi solo se qualcosa sta andando storto in questo code.please aiuto. Questo è il mio 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 | |
+----------------+---------------+------+-----+---------+----------------+
Non hai mostrato come hai assegnato l'istruzione ('st'). È necessario impostarlo aggiornabile nella chiamata 'createStatement'. –
Questo è anche lì Statement st = con.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); –
Hai provato ad aggiungere la clausola "FOR UPDATE" a SELECT? –