我尝试使用下面的代码向我的数据库添加一个新行,即使已在代码中明确说明,我仍然会收到该错误
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();
}
答案 0 :(得分:0)
尝试使用ResultSet.TYPE_SCROLL_INSENSITIVE或ResultSet.TYPE_SCROLL_SENSITIVE调用regis.setType