Exemple #1
0
  @Override
  public int delete(int key) {
    String sql = "DELETE FROM EmployeeLoginDetails WHERE empId = ?";
    int rowDeleted = 0;
    try {
      PreparedStatement pstmt = con.prepareStatement(sql);

      pstmt.setInt(1, key);

      rowDeleted = pstmt.executeUpdate();

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

    return rowDeleted;
  }
Exemple #2
0
  @Override
  public int add(User t) {
    String sql = "INSERT INTO EmployeeLoginDetails VALUES (?,?,?)";
    int rowAdded = 0;

    try {
      PreparedStatement pstmt = con.prepareStatement(sql);
      pstmt.setInt(1, t.getEmpId());
      pstmt.setString(2, t.getPassword());
      pstmt.setString(3, t.getRole());

      rowAdded = pstmt.executeUpdate();

    } catch (SQLException e) {
      e.printStackTrace();
    }

    return rowAdded;
  }
Exemple #3
0
  public int update(User u) {

    String sql = "UPDATE EmployeeLoginDetails SET password = ? , role = ? WHERE EmpId = ?";
    int rowUpdated = 0;
    try {
      PreparedStatement pstmt = con.prepareStatement(sql);

      pstmt.setString(1, u.getPassword());
      pstmt.setString(2, u.getRole());
      pstmt.setInt(2, u.getEmpId());

      rowUpdated = pstmt.executeUpdate();

    } catch (SQLException e) {
      e.printStackTrace();
    }

    return rowUpdated;
  }
Exemple #4
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;
  }