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

most efficient way to insert records in a DB

 
JP Estrada
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 626
Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are you updating records or inserting?
 
Scott Selikoff
author
Saloon Keeper
Posts: 4020
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic