use of io.bastillion.manage.model.Profile in project KeyBox by skavanagh.
the class ProfileDB method getAllProfiles.
/**
* returns all profile information
*
* @return list of profiles
*/
public static List<Profile> getAllProfiles() throws SQLException, GeneralSecurityException {
ArrayList<Profile> profileList = new ArrayList<>();
Connection con = DBUtils.getConn();
PreparedStatement stmt = con.prepareStatement("select * from profiles order by nm asc");
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
Profile profile = new Profile();
profile.setId(rs.getLong("id"));
profile.setNm(rs.getString("nm"));
profile.setDesc(rs.getString("desc"));
profileList.add(profile);
}
DBUtils.closeRs(rs);
DBUtils.closeStmt(stmt);
DBUtils.closeConn(con);
return profileList;
}
use of io.bastillion.manage.model.Profile in project KeyBox by skavanagh.
the class UserProfileDB method getProfilesByUser.
/**
* return a list of profiles for user
*
* @param userId user id
* @return profile list
*/
public static List<Profile> getProfilesByUser(Connection con, Long userId) throws SQLException {
ArrayList<Profile> profileList = new ArrayList<>();
PreparedStatement stmt = con.prepareStatement("select * from profiles g, user_map m where g.id=m.profile_id and m.user_id=? order by nm asc");
stmt.setLong(1, userId);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
Profile profile = new Profile();
profile.setId(rs.getLong("id"));
profile.setNm(rs.getString("nm"));
profile.setDesc(rs.getString("desc"));
profileList.add(profile);
}
DBUtils.closeRs(rs);
DBUtils.closeStmt(stmt);
return profileList;
}
Aggregations