java - insert cmr values into database -
i have cmr file different values, don't know how use separator. want store "numberpacketslost", "jitter", , "latency" mysql database using java netbeans button.
thanks! :)
code cmr file :
"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"
you need open cmr file, read through line line skipping headers , extract data. once needed data, write query insert database.
bufferedreader br = new bufferedreader(new filereader(new file("mycmrfile"))); string line = null; int linecount = 0; while ((line = br.readline()) != null){ if (linecount++ < 2) // skip headers continue; // split data , convert integers string[] data = line.split(","); integer packetslost = integer.valueof(data[10]); integer jitter = integer.valueof(data[11]); integer latency = integer.valueof(data[12]); // insert db, query string query = "insert mytable (numberpacketslost, jitter, latency) values(?,?,?)"; preparedstatement ps = connection.preparestatment(query); ps.setint(1, packetslost); ps.setint(2, jitter); ps.setint(3, latency); ps.executeupdate(); }
this code won't work exactly, need change around based on real values of database.
Comments
Post a Comment