Example #1
0
  public int passwordChange(String insName, String oldpw, String newpw)
      throws CentralStockDAOException {
    try {
      org.hibernate.classic.Session session = sessionFactory.getCurrentSession();

      Login existingUser = (Login) session.get(Login.class, insName);

      if (insName.equals(existingUser.getInsName()) && oldpw.equals(existingUser.getUserPw())) {

        String hql =
            "UPDATE Login i set i.userPw = '" + newpw + "'WHERE i.insName = '" + insName + "'";

        session.createQuery(hql).executeUpdate();

        return 1;
      } else {
        return 0;
      }
    } catch (HibernateException he) {
      throw new CentralStockDAOException(he + "");
    } catch (Exception sl) {
      throw new CentralStockDAOException(sl + "");
    }
  }
Example #2
0
  public int checkLogin(String insName, String user, String pwd) throws CentralStockDAOException {
    try {
      org.hibernate.classic.Session session = sessionFactory.getCurrentSession();

      Login existingUser = (Login) session.get(Login.class, insName);

      if (insName.equals("Centeral Admin")
          && user.equals(existingUser.getUserId())
          && pwd.equals(existingUser.getUserPw())) {
        return 1;
      } else if (insName.equals(existingUser.getInsName())
          && user.equals(existingUser.getUserId())
          && pwd.equals(existingUser.getUserPw())) {
        return 2;
      } else {
        return 0;
      }
    } catch (HibernateException he) {
      throw new CentralStockDAOException(he + "");
    } catch (Exception sl) {
      throw new CentralStockDAOException(sl + "");
    }
  }