Beispiel #1
0
 public boolean addMeDependent(AppDependentRelationPo po) {
   String sql =
       "insert into CSP_DEPENDENT_ME_DEP(self_site,self_ip,self_app_name,dependent_app_name,dependent_ip,"
           + "dependent_site,dependent_port,dependent_type,collect_time)"
           + "values(?,?,?,?,?,?,?,?,DATE_FORMAT(?,\"%Y-%m-%d\"))";
   try {
     this.execute(
         sql,
         new Object[] {
           po.getSelfSite(),
           po.getSelfIp(),
           po.getSelfOpsName(),
           po.getDependentOpsName(),
           po.getDependentIp(),
           po.getDependentSite(),
           po.getDependentPort(),
           po.getDependentType(),
           po.getCollectTime()
         });
   } catch (SQLException e) {
     logger.error("addAppDependentRelation", e);
     return true;
   }
   return false;
 }
Beispiel #2
0
  public AppDependentRelationPo getAppDependentRelation(
      String self, String dependent, Date collectTime) {
    String sql =
        "select * from CSP_DEPENDENT_APP_RELATION where self_app_name=? and dependent_app_name=? and collect_time=DATE_FORMAT(?,\"%Y-%m-%d\")";

    final AppDependentRelationPo po = new AppDependentRelationPo();

    try {
      this.query(
          sql,
          new Object[] {self, dependent, collectTime},
          new SqlCallBack() {

            @Override
            public void readerRows(ResultSet rs) throws Exception {
              po.setSelfOpsName(rs.getString("self_app_name"));
              po.setDependentOpsName(rs.getString("dependent_app_name"));
              po.setCollectTime(new Date(rs.getTimestamp("collect_time").getTime()));
            }
          });
    } catch (Exception e) {
      logger.error("getAppDependentRelation", e);
    }

    return po.getSelfOpsName() != null ? po : null;
  }