Example #1
0
  public void updateAdmBranch(AdmBranchTO admBranchTO) {
    PreparedStatement pstmt = null;
    Connection con = null;

    try {
      con = DAOFactory.getInstance().getConnection(Connection.TRANSACTION_READ_UNCOMMITTED);
      pstmt = con.prepareStatement(SQLConstants.UPDATE_ADM_BRANCH_SQL);
      pstmt.setString(1, Utility.trim(admBranchTO.getStatus()));
      pstmt.setInt(2, 1);
      pstmt.setString(3, Utility.trim(admBranchTO.getBranch().getId()));

      pstmt.executeUpdate();

    } catch (SQLException e) {
      throw new DataException(e.getMessage());
    } catch (NamingException e) {
      throw new DataException(e.getMessage());
    } finally {
      Utility.closeAll(null, pstmt, con);
    }
  }
Example #2
0
  public AdmBranchTO[] listAdmBranch(AdmTO admTO) {
    PreparedStatement pstmt = null;
    Connection con = null;
    ResultSet rs = null;
    AdmBranchTO admBranchTO = null;
    ArrayList<AdmBranchTO> admBranchList = new ArrayList<AdmBranchTO>();

    try {
      con = DAOFactory.getInstance().getConnection(Connection.TRANSACTION_READ_UNCOMMITTED);
      pstmt = con.prepareStatement(SQLConstants.LIST_ADMIN_BRANCH_SQL);
      pstmt.setString(1, Utility.trim(admTO.getId()));

      rs = pstmt.executeQuery();
      while (rs.next()) {
        BranchTO branchTO = new BranchTO();
        admBranchTO = new AdmBranchTO();
        admBranchTO.setAdm(admTO);

        admBranchTO.setId(rs.getString("id"));
        admBranchTO.setStatus(Utility.trim(rs.getString("status")));

        admBranchTO.setBranch(branchTO);
        admBranchTO.getBranch().setId(Utility.trim(rs.getString("branch_id")));
        admBranchTO.getBranch().setCode(Utility.trim(rs.getString("code")));
        admBranchTO.getBranch().setName(Utility.trim(rs.getString("name")));
        admBranchList.add(admBranchTO);
      }

      return (AdmBranchTO[]) admBranchList.toArray(new AdmBranchTO[0]);

    } catch (SQLException e) {
      throw new DataException(e.getMessage());
    } catch (NamingException e) {
      throw new DataException(e.getMessage());
    } finally {
      Utility.closeAll(null, pstmt, con);
    }
  }