예제 #1
0
  public EHVSS getByEhvssCode(String code) {
    EHVSS ehvss = new EHVSS();

    try {
      Connection connection = DatabaseConnection.getConnection("mms_new");
      PreparedStatement ps = connection.prepareStatement("SELECT * FROM ehvss where code=?");
      ps.setString(1, code);
      ResultSet rs = ps.executeQuery();
      while (rs.next()) {
        ehvss.setId(String.valueOf(rs.getInt(1)));
        ehvss.setName(rs.getString(3).trim());
        ehvss.setCode(rs.getString(2).trim());
        ehvss.setLocation(rs.getString(4).trim());
        ehvss.setRegion(rs.getString(5).trim());
        ehvss.setCircle(rs.getString(6).trim());
        ehvss.setDivision(rs.getString(7).trim());
      }
      rs.close();
      ps.close();

    } catch (SQLException e) {
      System.out.println("Exception in class : EhvssDAO : method : [getByEhvssCode]" + e);
    }
    return ehvss;
  }
예제 #2
0
 public ArrayList<EHVSS> getByCircle(String circle, String startIndex, String pageSize) {
   // System.out.println("GetByCircle called with circle : "+circle);
   ArrayList<EHVSS> ehvssNames = null;
   try {
     Connection connection = DatabaseConnection.getConnection("mms_new");
     PreparedStatement ps =
         connection.prepareStatement(
             "SELECT * FROM ehvss where circle=? limit " + startIndex + "," + pageSize);
     ps.setString(1, circle);
     ResultSet rs = ps.executeQuery();
     ehvssNames = new ArrayList<EHVSS>();
     while (rs.next()) {
       EHVSS ehvss = new EHVSS();
       ehvss.setId(String.valueOf(rs.getInt(1)));
       ehvss.setName(rs.getString(3).trim());
       ehvss.setCode(rs.getString(2).trim());
       ehvss.setLocation(rs.getString(4).trim());
       ehvss.setRegion(rs.getString(5).trim());
       ehvss.setCircle(rs.getString(6).trim());
       ehvss.setDivision(rs.getString(7).trim());
       ehvssNames.add(ehvss);
     }
     rs.close();
     ps.close();
     // System.out.println("Number of Ehvss Locations for region :"+region+"  is
     // :"+ehvssNames.size());
   } catch (SQLException e) {
     System.out.println(
         "Exception in class : EhvssDAO : method : [getByCircle(String,String,String)]" + e);
   } catch (Exception exp) {
     System.out.println(
         "Exception in class : EhvssDAO : method : [getByCircle(String,String,String)]" + exp);
   }
   return ehvssNames;
 }
예제 #3
0
 private void resultSetParser(ResultSet rs, ArrayList<EHVSS> ehvssNames) {
   try {
     while (rs.next()) {
       EHVSS ehvss = new EHVSS();
       ehvss.setId(String.valueOf(rs.getInt(1)));
       ehvss.setName(rs.getString(3).trim());
       ehvss.setCode(rs.getString(2).trim());
       ehvss.setLocation(rs.getString(4).trim());
       ehvss.setRegion(rs.getString(5).trim());
       ehvss.setCircle(rs.getString(6).trim());
       ehvss.setDivision(rs.getString(7).trim());
       ehvssNames.add(ehvss);
     }
   } catch (SQLException e) {
     System.out.println(
         "Exception in class : EhvssDAO : method : [resultSetParser(ResultSet,ArrayList<Substation>)]"
             + e);
   }
 }