Background:
In the interface, you need to take out all the IDs in the database, with Jmter to do some data association, the problem, the database ID converted to a character type, and the interface is required to use long type, so in the lead out, the data has been reported type is not long, then how to convert hundreds of data to long type, I'm using the SQLyog database, and here are the steps to export the data
Sqlyong How to export data
1. Select the data you want to export, the first one to export all data
2. Select the fields that need to be exported, select all by default, select them as required
3. Is saved to the file, the format can be determined by itself
4. Can be used to save the value of the escape character
converting Data
With the above type of conversion out, the default is all string type, but each ID, the manual to paste ID, normal, export to have problems, no way, write a small code to solve, as follows:
Public Static voidMain (string[] args)throwsNumberFormatException, IOException {//TODO auto-generated Method StubFile file=NewFile ("F:/dat/dynamicid2_zhang2.txt"); BufferedReader BR=NewBufferedReader (Newfilereader (file)); String s=NULL; while((S=br.readline ())! =NULL){ //S.trim (); //System.out.println (s);String Str2=s.replaceall ("", ""); LongL=Long.parselong (STR2); System.out.println (l); } }
All the data was turned into a long, and I was relieved to use the data.
Converting a string format from a database to a long type