예제 #1
1
 public String getONT() {
   Connection con;
   String ontid = null;
   String JsonStr = "{\"ont\": [";
   try {
     con = DataSource.getConnection();
     PreparedStatement pst = con.prepareStatement("select ont_id from ont");
     ResultSet rs = pst.executeQuery();
     int flag = 1;
     while (rs.next()) {
       flag = 0;
       ontid = rs.getString("ont_id");
       JsonStr += "{\"ont_id\":\"" + ontid + "\"},";
     }
     if (flag == 1) {
       JsonStr += ",";
     }
     int len = JsonStr.length();
     JsonStr = JsonStr.substring(0, len - 1);
     JsonStr += "],";
   } catch (SQLException | ClassNotFoundException e) {
     System.out.println("error connection to the database getponids" + e.getMessage());
     return "";
   }
   System.out.println(JsonStr);
   DataSource.returnConnection(con);
   return JsonStr;
 }
예제 #2
0
 public void updateOntStatus(String ontid, String status) {
   Connection con = null;
   try {
     con = DataSource.getConnection();
     PreparedStatement pst = con.prepareStatement("update ont set status=? where ont_id=?");
     pst.setString(1, status);
     pst.setString(2, ontid);
     pst.executeUpdate();
     pst.close();
   } catch (SQLException | ClassNotFoundException e) {
     System.out.println("in update ONT status" + e.getMessage());
   }
   DataSource.returnConnection(con);
 }
예제 #3
0
 public String getWirelessDetailsCustomer(String portid) {
   Connection con = null;
   String result = null;
   try {
     con = DataSource.getConnection();
     PreparedStatement ps =
         con.prepareStatement("SELECT CUSTOMER_ID,ONT_ID FROM ONT WHERE PON_PORT_ID=?");
     ps.setString(1, portid);
     ResultSet rs = ps.executeQuery();
     while (rs.next())
       result = rs.getString("CUSTOMER_ID") + "            " + rs.getString("ONT_ID");
   } catch (ClassNotFoundException | SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   DataSource.returnConnection(con);
   return result;
 }