• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

read text file and save data into database

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll have to use java.io and JDBC. What have you tried so far?
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't have to write that intermediate step where you store the data in a text file.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic