Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problems with batch update

 
John Ray Allen
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15272
37
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show us the source code instead of having us guess what your program is doing.
 
Sri Ram
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is a missing commit statement.
 
John Ray Allen
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 381
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any idea yet?..i haven't found any explanation as of now hope sumbody could help me..thanks!
 
Maximilian Xavier Stocker
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic