Converting a string format from a database to a long type

Source: Internet
Author: User
Tags string format

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.