// function
sql = "select f.id funId,f.name funName,r.id resId,r.name resName from function f join resource r on f.resid = r.id and f.id in (select funid from role_function where roleid= )";
PreparedStatement funPstmt = db.prepare(conn, sql);
ResultSet funRs = db.getResult(funPstmt,
new Object[] { roleId });
Function function = null;
Resource resource = null;
while (funRs.next()) {
resource = new Resource();
long resId = funRs.getLong("resId");
String resName = funRs.getString("resName");
resource.setId(resId);
resource.setObject(resName);
String funName = funRs.getString("funName");
// 得到默认的操作
function = FunctionFactory.getDefaultFunction(funName,
resource);
role.getFunctions().add(function);
}
}
db.close(rolePstmt, roleRs);
}
// db.close(conn, pstmt, rs);
db.close(pstmt, rs);
return user;
}
// public static void main(String[] args) throws SQLException,
// ClassNotFoundException {
// UserDAO dao = new UserDAO();
// dao.logger.debug("12") ;
// System.out.println(dao.conn);
// }
}
摘自 akwolf