Exemplo n.º 1
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;
  }
Exemplo n.º 2
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;
  }