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;
}
ResultSet 参数設置使用實例
最新推荐文章于 2024-06-04 15:46:25 发布