我尝试使用下面的代码向我的数据库添加新行,即使代码中已明确说明这一点,我仍然收到该错误
ResultSet rs12 = null;
String sql1 = ("Select admin.* From admin");
Statement st1 = cn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs12 = st1.executeQuery(sql1);
if(!rs12.equals(null))
{
JdbcRowSet regis = new JdbcRowSetImpl(rs12);
regis.setConcurrency(java.sql.ResultSet.CONCUR_UPDATABLE);
regis.last();
int id=Integer.parseInt(regis.getString("id"))+1;
regis.moveToInsertRow();
regis.updateInt("id", id);
regis.updateString("username", adminname);
regis.updateString("password", pass);
regis.insertRow();
regis.moveToCurrentRow();
textAdmin.setText("");
passwordAdmin.setText("");
passwordAdminConfirm.setText("");
JOptionPane.showMessageDialog(this, "You have Successfully Registered!");
log.close();
regis.close();
}
最佳答案
尝试使用 ResultSet.TYPE_SCROLL_INSENSITIVE 或 ResultSet.TYPE_SCROLL_SENSITIVE 调用 regis.setType
关于java - ResultSet 不可更新,即使其设置为 CONCUR_UPDATABLE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49931437/