首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

ResultSet 参数設放使用實例

2012-09-06 
ResultSet 参数設置使用實例public static String[][] getFunctionUser(String functionID) {Connection c

ResultSet 参数設置使用實例


public static String[][] getFunctionUser(String functionID) {Connection con = null;Statement stmt = null;ResultSet rs = null;String[][] returnArray = null;try {con = SimpleServlet.osmCP.getConnection();stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);rs = stmt.executeQuery("select c.userFName || ' ' || c.userLName as userName , c.loginID as userid, c.email from "  + "sysUserProfile c where c.functionID = '" + functionID + "'");rs.last();returnArray = new String[rs.getRow()][3];rs.beforeFirst();while (rs.next()) {returnArray[rs.getRow() - 1][0] = rs.getString("userName");returnArray[rs.getRow() - 1][1] = rs.getString("userid");returnArray[rs.getRow() - 1][2] = rs.getString("email");}} catch (SQLException e) {try {    if(con != null)       con.rollback();} catch (SQLException ex) {    System.out.println("SQLException: " + ex.toString());}System.out.println("SQLException: " + e.toString());e.printStackTrace();} catch (Exception e) {try {    if (con != null) con.rollback();} catch (SQLException ex) {    System.out.println("SQLException: " + ex.toString());}System.out.println("SQLException: " + e.toString());e.printStackTrace();} finally {try {     if (rs != null) rs.close();     if (stmt != null) stmt.close();     if (con != null)  SimpleServlet.osmCP.free(con);} catch (Exception ex) {     ex.printStackTrace();}}return returnArray; }
?


热点排行