ResultSet不可更新 [英] ResultSet is not updatable

查看:110
本文介绍了ResultSet不可更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了关于stackoverflow(以及网络上其他地方)的所有可更新"文章,但无济于事.我的代码工作正常,然后停止了,说结果集不可更新.这涉及我在JDBC derby数据库中使用的4个数据文件.这些文件都有密钥.我不知道还能去哪里.我在下面编写了测试代码来演示该问题.

I have read all of the "updatable" post on stackoverflow (and elsewhere on the web) but to no avail. My code was working fine then it stopped say the resultset was not updatable. This is across the 4 data files I use in the JDBC derby database. The files all have keys. I don't know where else to look. I wrote the test code below to demonstrate the problem.

     private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {                                      
try {
    String uName = "guest";
    String uPass = "guest";
    String host = "jdbc:derby://127.0.0.1:1527/erTracker";
    Connection erTrackerCon = DriverManager.getConnection( host,uName,uPass );
   // erTrackerCon.setAutoCommit(true);
     milestonesStmt = erTrackerCon.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    String SQL = "SELECT * FROM milestones order by milestoneID";
    rsMilestones = milestonesStmt.executeQuery( SQL ); 
    String a = "02";
    String b = "M";
    String c = "Move to prospect";
    erTrackerCon.setReadOnly(false);
    int concurrency = rsMilestones.getConcurrency();
    System.out.println("the answer is " + concurrency); // the answer is 1007
    rsMilestones.moveToInsertRow(); // error is: 'moveToInsertRow' not allowed because the ResultSet is not an updatable ResultSet. 
    rsMilestones.updateString("milestoneID", a);
    rsMilestones.updateString("milestoneType",b);
    rsMilestones.updateString("milestoneName", c);
    rsMilestones.insertRow( );  
   //String SQL =  "INSERT INTO milestones (milestoneid,milestonetype,milestongname) VALUES     ('02','M','move to pursue')";
   //rsMilestones = milestonesStmt.executeQuery( SQL );
}                                     
catch ( SQLException err ) {
   System.out.println( err.getMessage( ) );
   }
}

推荐答案

根据Derby文档(例如

According to the Derby documentation (e.g. here) you cannot use ORDER BY in an updatable resultset.

这篇关于ResultSet不可更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆