oracle的rowset实现在http://otn.oracle.com/software/content.html的jdbc下载里有,名称是ocrs12.zip
示例代码:
- //查询数据部分代码:
- importjavax.sql.RowSet;
- importoracle.jdbc.rowset.OracleCachedRowSet;
- …
- Connectionconn=DBUtil.getConnection();
- PreparedStatementpst=null;
- ResultSetrs=null;
- try{……
- Stringsql=“selectemp_code,real_namefromt_employeewhereorgan_id=?”;
- pst=conn.preparedStatement(sql);
- pst.setString(1,“101”);
- rs=pst.executeQuery();
- OracleCachedRowSetors=newOracleCachedRowSet();
- //将ResultSet中的数据封装到RowSet中
- ors.populate(rs);
- returnors;
- }finally{
- DBUtil.close(rs,pst,conn);
- }
- //JSP显示部分代码
- <%
- javax.sql.RowSetempRS=(javax.sql.RowSet)request.getAttribute(“empRS”);
- %>
- …
- <tablecellspacing="0"width=”90%”>
- <tr><td>代码</td><td>姓名</td></tr>
- <%
- if(empRS!=null)while(empRS.next()){
- %>
- <tr>
- <td><%=empRS.get(“EMP_CODE”)%></td>
- <td><%=empRS.get(“REAL_NAME”)%></td>
- </tr>
- <%
- }//endwhile
- %>
- </table>