This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes How can I do batch updates using PreparedStatements rather than Statements? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How can I do batch updates using PreparedStatements rather than Statements?" Watch "How can I do batch updates using PreparedStatements rather than Statements?" New topic
Author

How can I do batch updates using PreparedStatements rather than Statements?

Siddhartha Ghosh
Greenhorn

Joined: Jul 07, 2005
Posts: 16
I've seen a lot of JDBC Code samples and examples for doing batch updates using the plain Statement interface. But I want to do the batch updates using the PreparedStatement interface, and I don't want to use the addBatch(String sql) method that PreparedStatement inherits from the Statement interface. Rather I want to use the addBatch() method of the PreparedStatement that can re use the same statement along with various data values to form different statements of the batch. The problem is that I am a bit confused about the exact usage...
Can anyone give me a small example? Is the method invoked after setting a new set of data values or before setting it for each new batch statement?
Thanks in advance!


Siddhartha "Maverick" Ghosh <br />Sun Certified Java Programmer 1.4
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 852
http://www.exampledepot.com/egs/java.sql/BatchUpdate.html


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
Siddhartha Ghosh
Greenhorn

Joined: Jul 07, 2005
Posts: 16


Thanks a lot for helping me out Sir. This example was exactly what I needed. This is why I love this community. Thanks for replying so quickly... I am indebted!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I do batch updates using PreparedStatements rather than Statements?
 
Similar Threads
best programming practises of JDBC
Is it possible to use batch for SQL select statment
Fastest way to insert 1 Lac records in a table
what is difference between JDBC1 and JDBC2 ?
Use Multiple Insert Statements in Prepared Statements