• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC preparedStatement vs Stored Proc ?

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I have a large data (around 300mb,well formatted) in text file, I need to load them into DB. which way is better, JDBC preparedStatement vs Stored Proc ? what benefits or cost we will have ?

Thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35271
383
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Edward,
You have a tremendous amount of network bandwidth being used up. You'll want to avoid millions of roundtrips. This can be done with JDBC batch updates or a stored procedure.

Which makes most sense depends on what you need to do with the data. Is there logic involved? Database lookups?
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Which makes most sense depends on what you need to do with the data. Is there logic involved? Database lookups?


Let's make it simple, Say stock trading price and its volume. We need to insert into DB. What is the best way to do this ?

The only logic should be checking if some column is missed or wrong-data-type ...

Thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35271
383
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My first choice would actually be SQL Loader (if using oracle) or its equivalent in your database. This is basically a straight data load and I don't see a reason to involve Java.

If you do need JDBC, I would use a PreparedStatement with batch updates. The logic isn't complex enough to warrant a stored proc.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic