CachedRowSet crs = (CachedRowSet) getResultSet(sql); while (crs.next()) { System.out.print(crs.getString(1) + "/t"); System.out.print(crs.getString(2) + "/t"); System.out.println(crs.getString(3)); } public static ResultSet getResultSet(String sql) throws Exception { Connection conn = Oracle.getConnection(); System.out.println(conn); Statement stmt = conn.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery(sql); CachedRowSet crs = new CachedRowSetImpl(); crs.populate(rs); rs.close(); stmt.close(); conn.close(); return crs; }
Java 返回 Rowset
最新推荐文章于 2025-12-02 21:20:38 发布
本文介绍了一种使用Java中的CachedRowSet处理从Oracle数据库获取的数据的方法。通过创建连接并执行SQL查询,将结果集加载到CachedRowSet中,然后遍历打印出来。这种方法可以有效地管理和展示大量数据。
9254

被折叠的 条评论
为什么被折叠?



