*
The moose likes I/O and Streams and the fly likes Read Text FIle and put particular data in data base Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Read Text FIle and put particular data in data base" Watch "Read Text FIle and put particular data in data base" New topic
Author

Read Text FIle and put particular data in data base

karan chandok
Greenhorn

Joined: Jul 15, 2011
Posts: 25
"2011-6-14 16:3:56:468 # update_songList_central_Apply :: transIDISPATCH_P110256 # SUPDATE #reference_ID :: 1461758199 # Statement:com.mysql.jdbc.JDBC4CallableStatement@10b95f2: CALL proc_onsite_utility_transaction_response('1461758199','DISPATCH_P110256','25','SUPDATE','Idea','Assam','IMS','Sufiyana','','bf-song48980',@com_mysql_jdbc_outparam_out_mesg)out_para:1"



I am having text file with above mentioned data in every line

I want to insert only red coloured text into data base colums

Can anyone suggest how to do?

Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

You may do the following,
1. Split the line based on comma
2. Remove the surrounding single quotes
3. Take the necessary (red coloured text) data
4. Construct a INSERT statement, use JDBC and do the needful


S.D. MADHAN
Not many get the right opportunity !
karan chandok
Greenhorn

Joined: Jul 15, 2011
Posts: 25
Thanks Madhan

But that is my query

"How to select that particular(red text)" ony?

Can you please write code for that?It's very urgent
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

If you check out our AccessingFileFormats FAQ, section "Excel", you will find several CSV libraries. You can use one of these to assist you in steps 1-3 in Madhan's procedure. A single PreparedStatement will help you with step 4.

I personally have good experience with opencsv.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

karan chandok wrote:Can you please write code for that?It's very urgent

We are NotACodeMill. And please EaseUp; there's no such thing as "urgent" around here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read Text FIle and put particular data in data base
 
Similar Threads
shell script to get the end of line
jar in Jdk 1.7
How to convert from sql to xml
How to extract columns of coordinate values from text file (in java) ?
FTP upload