public class RowSetTest { public static void test() { CachedRowSet csr = null; try { csr = new CachedRowSetImpl(); RowSetMetaData rsmd = new RowSetMetaDataImpl(); rsmd.setColumnCount(2); rsmd.setColumnName(1, "col001"); rsmd.setColumnType(1, java.sql.Types.INTEGER); rsmd.setColumnName(2, "col002"); rsmd.setColumnType(2, java.sql.Types.INTEGER); csr.setMetaData(rsmd); csr.moveToInsertRow(); csr.updateObject(1, new Integer(12)); csr.updateObject(2, new Integer(1254)); csr.insertRow(); csr.moveToInsertRow(); csr.updateObject(1, new Integer(12)); csr.updateObject(2, new Integer(1254)); csr.insertRow(); csr.moveToCurrentRow(); csr.first(); do { int i1 = csr.getInt(1); int i2 = csr.getInt(2); System.out.println(i1 + ", " + i2); } while( csr.next()); } catch (SQLException e) { e.printStackTrace();//To change body of catch statement use File | Settings | File Templates. } } public static void main(String[] args) { test(); } } |
很好用的CachedRowSet
最新推荐文章于 2022-11-16 09:57:17 发布