aspose file tools*
The moose likes Beginning Java and the fly likes Regarding updating Database from Text file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Regarding updating Database from Text file." Watch "Regarding updating Database from Text file." New topic
Author

Regarding updating Database from Text file.

Prem Bhazee
Ranch Hand

Joined: Feb 18, 2006
Posts: 34
Hi Ranchers.

I am not sure is this the right forum for this question.

I am trying to come up with a logic for a small utility. Bascially I need to run a java program that will call a Stored Procedure to insert records
into a table from a text file which has several hundred rows. If the rows are being appended to the text file everytime to the existing rows how can I know until which rowcounts I have updated last time to the database after the program runs.I mean if I have updated 1-100 row the first time how can I keep track so that I will start updating from the 101 row on the next run. Do you think I should keep an indicator which updates the text file so that next time I will know which rows have been updated. Or is there anyother mechanism to do this relatively easily.

Please advise. Thanks in advance.

Bhazee
Guido Sautter
Ranch Hand

Joined: Dec 22, 2004
Posts: 142
Hi Prem,

how about processing the whole file in one run, line by line, and then renaming it to some name that indicates to your tool the file is done. Finally, put an empty file with the same name as your data file originally had, so newly arriving data can be appended to it.

If your tool is the only thing that modifies the database, you might also use SELECT count(*) to dertermine the number of tupels already in the database table, and skip an according number of lines in the file.

Yet another option would be using timestamps.
Prem Bhazee
Ranch Hand

Joined: Feb 18, 2006
Posts: 34
Guido

Thanks for your information. Also when you mentioned about Timestamps just wondering what you had in mind.Just trying to come up with the best approach.

Thanks
Bhazee
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding updating Database from Text file.