知道后麻烦也告诉我。谢谢
[email protected]

解决方案 »

  1.   

    我现在知道怎么返回更新数据集了,但还有另一个问题。jdk的help上说:
    insertRow
    public void insertRow()
    throws SQLException 
    Inserts the contents of the insert row into this ResultSet objaect and into the database. The cursor must be on the insert row when this method is called.但我发觉插入数据时只是插入到数据库,没有插入到resultset:
    String sql = "select c.* from table1 c";
    Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    ResultSet resultset = stmt.executeQuery(sql);       resultset.moveToInsertRow();
    resultset.updateInt("1", 100);       
    resultset.insertRow();       
    resultset.beforeFirst();       
    int count = 0;       
    while (resultset.next()) {          
    count++;       
    }       
    System.out.println(count+" records");执行前table1是空的,执行后得到的输出是0 records,table1里已插入了这条记录。这与帮助说的不一样。我想插入一条记录后,做一些操作,然后通过resultset再更新这条记录就不行了,谁知道为什么在resultset插入记录后,resultset里没有这条记录?
      

  2.   

    你的JDBC驱动不一定支持这个功能,检查一下:
    Connection conn;
    boolean b = conn.getMetaData().ownInsertsAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE);
    看看b是true还是false。
      

  3.   

    to jimjxr:
    我已经去下载了最新的oracle jdbc驱动,但是TYPE_FORWARD_ONLY,TYPE_SCROLL_INSENSITIVE,TYPE_SCROLL_SENSITIVE我都试过了,b还是false,那就是说oracle根本不支持这个特性了,是吧?你是怎么解决这个问题?to waterdragonfly:
    你看看前后2个帖子里的sql语句有什么不同就知道了,这可能是一个bug,我也不清楚,我也是去别的地方找到的。
      

  4.   

    我看了手册,是不支持的。我没这么用过,一般都是用Statement运行SQL INSERT的。