Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in batch update

 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I'm facing a problem in Batch Update , I'm adding many insert statements in batch but only one statement is getting executed.

This is my code



Help me in this
[ January 05, 2005: Message edited by: srini vasan ]
 
Rajendar Goud
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Srini,
How did u conclude that only one statement is executed and not the others? is it based on the updatecount values you printed ?

but the api mentions something like

The int elements of the array that is returned are ordered to correspond to the commands in the batch, which are ordered according to the order in which they were added to the batch. The elements in the array returned by the method executeBatch may be one of the following:
A number greater than or equal to zero -- indicates that the command was processed successfully and is an update count giving the number of rows in the database that were affected by the command's execution
A value of SUCCESS_NO_INFO -- indicates that the command was processed successfully but that the number of rows affected is unknown

did u checked out the database results manually ?
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Srini ,

problem is at this line ----> batchStmt = connection.createStatement();

you are creating statement every time the loop execute,and that is why you are facing problem.

keep this line out of loop and It will work.


[ January 05, 2005: Message edited by: Shailesh Chandra ]
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shailesh ,Yes thats a problem ..
Cha what a silly thing..
I'm, very sorry to post messages like this.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajendar Goud
Yes i checked the DB.. any way thanks for the reply
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by srini vasan:

I'm, very sorry to post messages like this.


We learn by mistakes only .... so I think one should not feel sorry ...

anyway cheers
[ January 05, 2005: Message edited by: Shailesh Chandra ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic