File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and Relational Databases and the fly likes most efficient way to insert records in a DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "most efficient way to insert records in a DB" Watch "most efficient way to insert records in a DB" New topic
Author

most efficient way to insert records in a DB

JP Estrada
Ranch Hand

Joined: Mar 21, 2006
Posts: 48
hi guys,

I'm using the PreparedStatements's executeUpdate method. But sometimes there are blockings that occur in SQLServer that prevent the record from being inserted...

What is the most efficient way of inserting records in MS SQL 2000?
Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 626

are you updating records or inserting?
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3740
    
  10

Order your all of you inserts/updates in a single transaction to always update all tables in a specific order (for example, always update table A before table B, table B before table c, etc for all transactions). This prevents locking due to cycles.

Many times though, such ordering is difficult to implement.


[OCA 8 Book] [Blog]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: most efficient way to insert records in a DB
 
It's not a secret anymore!