• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.exampledepot.com/egs/java.sql/BatchUpdate.html
 
Siddhartha Ghosh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by steve souza:
http://www.exampledepot.com/egs/java.sql/BatchUpdate.html



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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!