Use rowset
RowSet is the interface provided in JDBC2.0, and Oracle has a corresponding implementation of the interface, which is useful for oracle.jdbc.rowset.OracleCachedRowSet. OracleCachedRowSet implements all methods in the ResultSet, but with the resultSet is that the data in OracleCachedRowSet is still valid after the Connection is shut down.
Oracle's RowSet is implemented in http://otn.oracle.com/software/content.html, name is Ocrs12.zip
Sample code:
// query data portion of the code: import javax.sql.RowSet; import oracle.jdbc.rowset.OracleCachedRowSet; Connection conn = DBUtil.getConnection (); PreparedStatement pst = null; ResultSet rs = null; try {String sql = "select emp_code , real_name from t_employee where organ_id =? "; pst = conn.preparedStatement (sql); pst.setString (1," 101 "); rs = pst.executeQuery (); OracleCachedRowSet ors = newOracleCachedRowSet (); // in the ResultSet Data package to ors.populate (} finally {dbutil.close (RS, PST, CONN);} Finally {DBUTIL.CLOSE