aspose file tools*
The moose likes JDBC and the fly likes problems with batch update Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "problems with batch update" Watch "problems with batch update" New topic
Author

problems with batch update

John Ray Allen
Ranch Hand

Joined: Jan 06, 2005
Posts: 50
i am using addBatch() to insert multiple sql statements and execute it using executeBatch() later..my problem is that when my batch is composed of update statements, only the last update statement is being executed and the rest is not updated...i am not getting any exception messages so my questions are is it a driver issue? or do i have to use delimeter for evry statements like whitespaces or carriage return? any idea is very much appreciated..tnx
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884
    
  10

Show us the source code instead of having us guess what your program is doing.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Sri Ram
Ranch Hand

Joined: Oct 03, 2005
Posts: 118
My guess is a missing commit statement.
John Ray Allen
Ranch Hand

Joined: Jan 06, 2005
Posts: 50
my codes goes sumthing like this

String up_str="";
(for ctr=0;ctr<count;ctr++){
up_str="update table_name set table_name_column1='EP' where table_name_column2="+ctr;
stmt.addBatch(up_str);
}
stmt.executeBatch();

what happens is that only the last string being added to the batch is being updated the rest remains the same..im not receiving any exception messages on my logs..my jdbc driver is classes12.jar of oracle jdeveloper..i even use their downloadable jdbc driver for oracle10g (9.0.2.0) dbase..hope you could help me..thanx
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
I think you need to post your actual code because it is is rather difficult to see what exactly you are doing with str in the code you posted and I do wonder what other things might be going on.

So since there is most likely a bug in your code it would be most helpful in us helping you if we saw your actual code and not just what you recall.
[ December 13, 2005: Message edited by: Maximilian Stocker ]
John Ray Allen
Ranch Hand

Joined: Jan 06, 2005
Posts: 50
well that's the pseudocode of my program actualy what it does is that as the for loop is being executed it adds an "update statement" take note all the statements being added to the batch is an "update" statement and not a "select statement" or "insert" statement..i have read alot about batchUpdates but i haven't seen any explanation regarding "multiple updates" batch, only "inserts" and "selects"..i also read something about driver issues..hope sumbody could help me..tnx to all of u guys!
John Ray Allen
Ranch Hand

Joined: Jan 06, 2005
Posts: 50
any idea yet?..i haven't found any explanation as of now hope sumbody could help me..thanks!
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Originally posted by John Ray Allen:
any idea yet?..i haven't found any explanation as of now hope sumbody could help me..thanks!

Dear John,

I think the idea remains the same as suggested earlier. There is a bug of some sort in your code.

For more specific help please post your actual code. Pseudo code is of no value in debugging your actual code. There are countless things the problem could be but we won't really be able to help you without seeing your actual code.

A wild stab in the dark would be that whatever count (the magic number in your pseudo code that you break your loop at) is 1.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problems with batch update
 
Similar Threads
Batch updation
Batch Execution Solution
Delete from multiple tables.
Batch Update question
Batch Updates