java,运行提示mysql.jdbc.NotUpdatable:Result Set not updatable,代码如下。求助
publicvoidupdatresult(){DButilutil=newDButil();Connectionconn=util.openConnection();S...
public void updatresult(){
DButil util = new DButil();
Connection conn = util.openConnection();
String sql = "select username,password,money from userinfo";
Statement stmt;
try{
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery(sql);
rs.absolute(num);
rs.updateInt("money",M);
rs.updateRow();
}catch (SQLException e) {
e.printStackTrace();
}
}
还需要其他部分代码么
(referenced table has no primary keys).This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table.
好像是说没有主键? 展开
DButil util = new DButil();
Connection conn = util.openConnection();
String sql = "select username,password,money from userinfo";
Statement stmt;
try{
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery(sql);
rs.absolute(num);
rs.updateInt("money",M);
rs.updateRow();
}catch (SQLException e) {
e.printStackTrace();
}
}
还需要其他部分代码么
(referenced table has no primary keys).This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table.
好像是说没有主键? 展开
1个回答
展开全部
这个可能是数据库方面的错误哦, 能看看wo的网名吗?这个问题能帮忙解决一下啊 、
私聊搞定吧
私聊搞定吧
追问
String sql = "select username,password,money from userinfo";
这句话我没加表的主键项 后来我改成
String sql = "select username,password,money,id from userinfo";
就OK了……
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询