resultset 使用实例

  1. public static String[][] getFunctionUser(String functionID) {  
  2.     Connection con = null;  
  3.     Statement stmt = null;  
  4.     ResultSet rs = null;  
  5.     String[][] returnArray = null;  
  6.     try {  
  7.         con = SimpleServlet.osmCP.getConnection();  
  8.         stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);  
  9.   
  10.         rs = stmt.executeQuery("select c.userFName || ' ' || c.userLName as userName , c.loginID as userid, c.email from "  
  11.                   + "sysUserProfile c where c.functionID = '" + functionID + "'");  
  12.         rs.last();  
  13.         returnArray = new String[rs.getRow()][3];  
  14.         rs.beforeFirst();  
  15.         while (rs.next()) {  
  16.             returnArray[rs.getRow() - 1][0] = rs.getString("userName");  
  17.             returnArray[rs.getRow() - 1][1] = rs.getString("userid");  
  18.             returnArray[rs.getRow() - 1][2] = rs.getString("email");  
  19.         }  
  20.     } catch (SQLException e) {  
  21.         try {  
  22.             if(con != null)  
  23.                con.rollback();  
  24.         } catch (SQLException ex) {  
  25.             System.out.println("SQLException: " + ex.toString());  
  26.         }  
  27.         System.out.println("SQLException: " + e.toString());  
  28.         e.printStackTrace();  
  29.     } catch (Exception e) {  
  30.         try {  
  31.             if (con != null) con.rollback();  
  32.         } catch (SQLException ex) {  
  33.             System.out.println("SQLException: " + ex.toString());  
  34.         }  
  35.         System.out.println("SQLException: " + e.toString());  
  36.         e.printStackTrace();  
  37.     } finally {  
  38.         try {  
  39.              if (rs != null) rs.close();  
  40.              if (stmt != null) stmt.close();  
  41.              if (con != null)  SimpleServlet.osmCP.free(con);  
  42.         } catch (Exception ex) {  
  43.              ex.printStackTrace();  
  44.         }  
  45.     }  
  46.     return returnArray;   
  47. }  
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值