예제 #1
0
  public List<User> getAll() {

    try {

      connection = connectionFactory.getConnection();

      String sql = "SELECT * FROM eeproject.Login;";
      Statement statement = connection.createStatement();

      ResultSet rs = statement.executeQuery(sql);

      while (rs.next()) {
        User user = new User();
        user.setUsername(rs.getString(1));
        user.setPassword(rs.getString(2));

        LOG.log(Level.INFO, "User: "******"List size: " + list.size());
      }

    } catch (SQLException ex) {
      LOG.log(Level.SEVERE, null, ex);
    } finally {
      connectionFactory.closeConnection();
      LOG.log(Level.INFO, "Connection closed");
    }

    return list;
  }