コード例 #1
0
 public void processVmProcessData() {
   try {
     PreparedStatement pstmt = sqlConnection.prepareStatement(Queries.getSqlInsertVmCpuInfo());
     AggregationOutput aggregationOutput =
         mongoTask.getAggregatedOutput("procinfo", Queries.getProcessInfoQuery());
     for (DBObject obj : aggregationOutput.results()) {
       String hostname = (String) obj.get("_id");
       double processes = Double.parseDouble(obj.get("processes").toString());
       double threads = Double.parseDouble(obj.get("threads").toString());
       pstmt.setTimestamp(1, new java.sql.Timestamp(timeStamp.getTime()));
       pstmt.setString(2, hostname);
       pstmt.setDouble(3, processes);
       pstmt.setDouble(4, threads);
       pstmt.setInt(5, 1);
       pstmt.addBatch();
     }
     pstmt.executeBatch();
   } catch (SQLException s) {
     s.printStackTrace();
   }
 }