public void processHostTaskData() { try { PreparedStatement pstmt = sqlConnection.prepareStatement(Queries.getSqlInsertHostTaskInfo()); AggregationOutput aggregationOutput = mongoTask.getAggregatedOutput("task", Queries.getHostTaskInfoQuery()); for (DBObject obj : aggregationOutput.results()) { String timeStamp = (String) obj.get("timestamp"); String action = (String) obj.get("action"); String target = (String) obj.get("target"); double timeTaken = Double.parseDouble(obj.get("timeTaken").toString()); pstmt.setTimestamp( 1, new java.sql.Timestamp( MongoAggregationHelper.jsonDateFormat.parse(timeStamp).getTime())); pstmt.setString(2, target); pstmt.setString(3, action); pstmt.setDouble(4, timeTaken); pstmt.setInt(5, 1); pstmt.addBatch(); } pstmt.executeBatch(); } catch (SQLException | ParseException s) { s.printStackTrace(); } }