Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with executeBatch()

843859Jul 3 2009 — edited Nov 20 2014
Hi!

I am currently developing an application that parses text files and inserts the found records into a Microsoft Access database. At the moment, I am trying to tune it's performance somewhat, and among other things I wish to perform these inserts in batches instead of separate queries.

I wrote a simple if statement with a counter that executed the batch every for every n:th command, but I soon realized that it didn't work very well. The execution stops after what I at first thought to be a random number of queries, but after printing all queries I noticed that it always stops when reaching an insert statement for a different table.

For example, let's say I have a batch of five queries that I want to execute.
INSERT INTO [Table1] VALUES ( 1, 'Some value' )
INSERT INTO [Table1] VALUES ( 2, 'Some value' )
INSERT INTO [Table1] VALUES ( 3, 'Some value' )
INSERT INTO [Table2] VALUES ( 4, 'Some value' )
INSERT INTO [Table2] VALUES ( 5, 'Some value' )
When calling executeBatch() it will successfully insert rows 1, 2 and 3 into Table1, but then it will stop. That is, the returning array of ints only has a length of three, instead of the expected five.

Any ideas of how to solve this?

Best regards,
Erik Brännström
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 4 2009
Added on Jul 3 2009
18 comments
1,714 views