0

値が異なる CMR ファイルがありますが、セパレータの使い方がわかりません。「numberPacketsLost」、「jitter」、および「latency」を、ボタン付きの Java netbeans を使用して mySQL データベースに保存したいと考えています。

ありがとう!:)

cmr ファイルからのコード:

"cdrRecordType","globalCallID_callManagerId","globalCallID_callId","nodeId","directoryNum","callIdentifier","dateTimeStamp","numberPacketsSent","numberOctetsSent","numberPacketsReceived","numberOctetsReceived","numberPacketsLost","jitter","latency","pkid","directoryNumPartition","globalCallId_ClusterID","deviceName","varVQMetrics"
INTEGER,INTEGER,INTEGER,INTEGER,VARCHAR(50),INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,UNIQUEIDENTIFIER,VARCHAR(50),VARCHAR(50),VARCHAR(129),VARCHAR(600)
2,2,1732470,2,"4241",47660016,1319556369,192,33024,191,32852,0,0,0,"8ea4f719-c49c-4456-a2a8-972ebcfb57a9","2b494acb-9359-7f52-b0ef-7b66bb672b73","StandAloneCluster","SEP0026CB3C2A16","MLQK=0.0000;MLQKav=0.0000;MLQKmn=0.0000;MLQKmx=0.0000;ICR=0.0000;CCR=0.0000;ICRmx=0.0000;CS=0;SCS=0;MLQKvr=0.95"
2,2,1732447,2,"5352",47659963,1319556371,1409,242348,1408,242176,0,0,0,"61ca6d9f-8e75-4282-b303-3fea2fa75df7","2b494acb-9359-7f52-b0ef-7b66bb672b73","StandAloneCluster","SEP64168D506D26","MLQK=4.5000;MLQKav=4.3554;MLQKmn=4.1440;MLQKmx=4.5000;ICR=0.0000;CCR=0.0029;ICRmx=0.0263;CS=1;SCS=1;MLQKvr=0.95"
2,2,1732134,2,"5502",47658367,1319556373,28529,4906988,28537,4908364,0,0,0,"d1717925-89bf-41b4-b122-6162db89128f","2b494acb-9359-7f52-b0ef-7b66bb672b73","StandAloneCluster","SEP64168D50A4DB","MLQK=4.5000;MLQKav=4.4570;MLQKmn=4.1440;MLQKmx=4.5000;MLQKvr=0.95;CCR=0.0011;ICR=0.0000;ICRmx=0.0267;CS=9;SCS=9"
4

1 に答える 1

0

cmr ファイルを開き、ヘッダーをスキップして行ごとに読み、データを抽出する必要があります。必要なデータを取得したら、データベースに挿入するクエリを作成するだけです。

BufferedReader br = new BufferedReader(new FileReader(new File("myCmrFile")));
String line = null;
int linecount = 0;
while ((line = br.readLine()) != null){
    if (linecount++ < 2) // skip the headers
        continue;
    // split the data and convert to integers
    String[] data = line.split(",");
    Integer packetsLost = Integer.valueOf(data[10]); 
    Integer jitter = Integer.valueOf(data[11]); 
    Integer latency = Integer.valueOf(data[12]); 
    // now insert into the db, query will look something like this
    String query = "INSERT INTO myTable (numberPacketsLost, jitter, latency) VALUES(?,?,?)";
    PreparedStatement ps = connection.prepareStatment(query);
    ps.setInt(1, packetsLost);
    ps.setInt(2, jitter);
    ps.setInt(3, latency);
    ps.executeUpdate();
}

このコードは正確には機能しません。データベースの実際の値に基づいて変更する必要があります。

于 2013-05-20T13:56:05.200 に答える