Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Reb
- @Override
- public Result<Map<String, String>> getUsers() {
- final String SQL = "SELECT name, username FROM Person";
- try (PreparedStatement p = c.prepareStatement(SQL)) {
- ResultSet r = p.executeQuery();
- Map<String, String> userlist = new HashMap<String, String> ();
- while (r.next()) {
- String name = r.getString("name");
- String username = r.getString("username");
- userlist.put = (name, username);
- }
- if (!userlist.isEmpty()) {
- return Result.success(userlist);
- }else {
- return Result.failure("No users exist");
- }
- }catch (SQLException e){
- throw new UnsupportedOperationException("This should get some users." + e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement