Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Suggestions for - read text from a txt file and dump into Database

 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !

I am trying to make some code which will read text from a file and then dump it into MySQL database. It seems to be quite easy
and there are plenty of samples around to learn from and make code that does the job.

Now, the problem is that I want to see what are the different possible ways in which one could do this thing and which would be the best way.
I welcome all suggestions.

Thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you could share what you've learned about different approaches? There isn't going to be "one best way", but we could comment on tradeoffs for what you are considering.

Showing you've done this research helps people provide better answers. Otherwise you are left with:
1) Read file
2) Write JDBC

Clearly this is too high level to answer your question
 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Maybe you could share what you've learned about different approaches? There isn't going to be "one best way", but we could comment on tradeoffs for what you are considering.

Showing you've done this research helps people provide better answers. Otherwise you are left with:
1) Read file
2) Write JDBC

Clearly this is too high level to answer your question


Okay. I will come back with some concrete answers.


But for now, I will say that I might have to dump a lot of values 10k-25k into a DB. So, certainly this approach won't work:
1- create string
2- reassign the word being read to that string.
3- dump the string into the appropriate place in the DB.

Best alternative to the above - String Builder ?

 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even going further, how about reading records in a chunk and inserting in DB? Or having two threads - one will keep on reading the records, and another would keep on inserting in DB?

I hope this helps.
 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anayonkar Shivalkar wrote:Even going further, how about reading records in a chunk and inserting in DB? Or having two threads - one will keep on reading the records, and another would keep on inserting in DB?

I hope this helps.


Thanks. I will try to do that too.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic