Пример #1
0
  public boolean update_Employee(EmployeeRegForm er) throws SQLException {
    PreparedStatement ps = null, ps2 = null;
    DBConn db = new DBConn();
    String ps_name = null;
    System.out.println("hia");
    con = db.getConnection();
    System.out.println(er.getEmp_firstname());
    boolean flag = false;
    try {
      ps =
          con.prepareStatement(
              "update Employee_reg set ps_id=?,dept_name=?,emp_id=?,emp_firstname=?,emp_lastname=?,sex=?,join_date=?,designation=? where emp_id='"
                  + er.getDemp_id()
                  + "'");

      ps.setInt(1, er.getPs_id());
      ps.setString(2, er.getDept_name());
      ps.setString(3, er.getEmp_id());
      ps.setString(4, er.getEmp_firstname());
      ps.setString(5, er.getEmp_lastname());
      ps.setString(6, er.getSex());
      ps.setString(7, er.getJoin_date());
      ps.setString(8, er.getDesignation());

      int i = ps.executeUpdate();

      if (i > 0) {
        flag = true;
        con.commit();
        System.out.println("NO");
      }

    } catch (Exception e) {
      e.printStackTrace();
      try {
        con.close();
      } catch (Exception e1) {
        e1.printStackTrace();
      }
    } finally {
      releaseResources(con, ps);
    }
    return flag;
  }
Пример #2
0
  public boolean empreg_insert(EmployeeRegForm ef) throws SQLException {
    PreparedStatement ps1 = null, ps2 = null;
    DBConn db = new DBConn();
    String ps_name = null;

    con = db.getConnection();

    boolean flag = false;
    try {

      ps1 = con.prepareStatement("insert into employee_reg values(?,?,?,?,?,?,?,?,?)");

      ps1.setInt(1, ef.getPs_id());
      ps1.setString(2, ef.getDept_name());
      ps1.setString(3, ef.getEmp_id());
      ps1.setString(4, ef.getEmp_firstname());
      ps1.setString(5, ef.getEmp_lastname());
      ps1.setString(6, ef.getSex());
      ps1.setString(7, ef.getJoin_date());
      ps1.setString(8, ef.getDesignation());
      ps1.setString(9, ef.getLoginid());
      System.out.println("I am executed chai");

      int i = ps1.executeUpdate();

      if (i > 0) {
        flag = true;
        con.commit();
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      releaseResources(con, ps1);
    }
    return flag;
  }