Example #1
0
  @Override
  public List<User> findAll() {
    String sql = "SELECT * FROM EmployeeLoginDetails";

    ArrayList<User> list = new ArrayList<User>();
    try {

      PreparedStatement pstmt = con.prepareStatement(sql);

      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        User us = getUser(rs);
        list.add(us);
      }

    } catch (SQLException e) {

      e.printStackTrace();
    }

    return list;
  }
Example #2
0
  @Override
  public User find(int key) {
    User us = null;
    String sql = "SELECT * FROM EmployeeLoginDetails WHERE EmpId = ?";

    try {
      PreparedStatement pstmt = con.prepareStatement(sql);

      pstmt.setInt(1, key);

      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        us = getUser(rs);
      }

    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return us;
  }