File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes read text file and save data into database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "read text file and save data into database" Watch "read text file and save data into database" New topic
Author

read text file and save data into database

albert sie
Ranch Hand

Joined: Jan 15, 2006
Posts: 108
i wan't to know that if i write all the data in another data into text file and then i want to read from the text file and save the database in another database. how i have to write this program to read data from the text file and save the data into another database

hope anyone here can give some opinion or giv some light to me thank you

regards,
albert


JAVA the only can called technology
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You'll have to use java.io and JDBC. What have you tried so far?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Your post is confusing. What exactly are you charged with doing? If it is simply parsing a file and inserting data into a database, there are plenty of tools that can do what without any programming. What makes you think that you need to use Java?

And how is this advanced?


There is no emoticon for what I am feeling!
vishwanath nadimpally
Ranch Hand

Joined: Jan 25, 2005
Posts: 116
If you are really asking "How can I read data from a text file and insert the rows in to a table in a database?" then the answer is :

use I/O methods to read the text file in to an ArrayList. Something like :


Make sure the text file is properly formatted and have some kind of a separator (say |) between columns and then use JDBC to insert the data in to the table.

[ March 30, 2006: Message edited by: vishwanath nadimpally ]
[ March 30, 2006: Message edited by: vishwanath nadimpally ]
albert sie
Ranch Hand

Joined: Jan 15, 2006
Posts: 108
thanks vishwanath nadimpally you posting really will help me.

what i want to say is, i want to transform the data from the informix database to the MySql database. for do this i need to retrieve the data from the informix database and write into the text file with the seperator(|) and line break (/n). what i need to do is to write the java program that can read the data from the text file and put back the data in the mysql database, that's my case.

So any opinion and comment or suggestion, please...please... enlighten me.

thank you... thank you...

regards,
albert
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Do you *have to* do the intermediate step of storing the data in a file? Why not select the data from the first database and immediately insert it into the second database? This would avoid the fiddly bits of parsing.
albert sie
Ranch Hand

Joined: Jan 15, 2006
Posts: 108
can do like this??
coz i transfer informix database data to the MySQL server data.
if can provide me the solution on how to do it or any other reference.
thank you.

regards,
albert
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Originally posted by albert sie:
can do like this??
coz i transfer informix database data to the MySQL server data.
if can provide me the solution on how to do it or any other reference.


Isn't not clear what you are refering to. Can you write code that reads from the first database? Cand you write code that writes to the second database? Can you stick these two together?
albert sie
Ranch Hand

Joined: Jan 15, 2006
Posts: 108
i mean is it can transfer directly the data from 1st database to the second database without passing in to the text file? coz my 1st database is informix and the 2nd database is MySQL, both is different database.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
You don't have to write that intermediate step where you store the data in a text file.
 
 
subject: read text file and save data into database