aspose file tools
The moose likes JDBC and the fly likes Problem in batch update Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Problem in batch update" Watch "Problem in batch update" New topic
Author

Problem in batch update

Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
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 ]

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
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

Joined: Aug 13, 2004
Posts: 1076

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 ]

Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Shailesh ,Yes thats a problem ..
Cha what a silly thing..
I'm, very sorry to post messages like this.
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Rajendar Goud
Yes i checked the DB.. any way thanks for the reply
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1076

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 ]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Problem in batch update
 
Similar Threads
Problem with addBatch ....
set commit size in spring
getting problem while inserting data into database by using executebatch
problem in inserting data using executebatch
Problem inserting a single quote (')