读书人

ResultSet 参数放使用例

发布时间: 2012-09-06 10:37:01 作者: rapoo

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; }
?


读书人网 >编程

热点推荐