This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to update a row using batchUpdate? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to update a row using batchUpdate?" Watch "How to update a row using batchUpdate?" New topic
Author

How to update a row using batchUpdate?

Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

HI All,

I am facing a problem when updating a set of rows using batch updates.

Please see the code:
pStmt = con.prepareStatement(MeetPointSQLConstants.MPE_UPDATE_CONTACT_INFO);
System.out.println("Inside Update3");
pStmt.setString(1, mpeView.getOecContactInfo1().getContactName());
pStmt.setString(2, mpeView.getOecContactInfo1().getTelArea());
pStmt.setString(3, mpeView.getOecContactInfo1().getTelExch());
pStmt.setString(4, mpeView.getOecContactInfo1().getTelNum());
pStmt.setLong(5, asrId);
pStmt.setString(6, mpeView.getOecContactInfo1().getContactTyp());
pStmt.addBatch();
System.out.println("Inside Update4");
pStmt.setString(1, mpeView.getOecContactInfo2().getContactName());
pStmt.setString(2, mpeView.getOecContactInfo2().getTelArea());
pStmt.setString(3, mpeView.getOecContactInfo2().getTelExch());
pStmt.setString(4, mpeView.getOecContactInfo2().getTelNum());
pStmt.setLong(5, asrId);
pStmt.setString(6, mpeView.getOecContactInfo2().getContactTyp());
pStmt.addBatch();
pStmt.executeBatch();

Thanx in advance.

[Bear edit: removed "urgent" from the subject]
[ July 28, 2005: Message edited by: Bear Bibeault ]

Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

When i execute this code, browser is not responding it stops when stmt.executeUpdate() is called.
vu lee
Ranch Hand

Joined: Apr 19, 2005
Posts: 189
Krisna,
The down size of executeBatch() is that if one of the records being locked by other process, it could take a while to either response or timeout.
 
Consider Paul's rocket mass heater.
 
subject: How to update a row using batchUpdate?
 
Similar Threads
java.sql.SQLException: Parameter index out of range (1 > number of parameters, which
database and xml
insert into method
Batch insertion problem
JDBC VRE 2.0 BatchUpdate