Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I insert multiple rows into a database in a single transaction?

0
Posted

How can I insert multiple rows into a database in a single transaction?

0

Location: http://www.jguru.com/faq/view.jsp?EID=226749 Created: Oct 11, 2000 Modified: 2000-10-15 08:32:49.388 Author: Anil Datt (http://www.jguru.com/guru/viewbio.jsp?EID=20887) Question originally posed by Ravi Shankar (http://www.jguru.com/guru/viewbio.jsp?EID=223578 //turn off the implicit commit Connection.setAutoCommit(false); //..your insert/update/delete goes here Connection.Commit(); a new transaction is implicitly started. Joe Sam Shirah comments: This question could be taken a couple of ways, so we included this answer as well: Ryan Breidenbach adds: JDBC 2.0 provides a set of methods for executing a batch of database commands. Specifically, the java.sql.Statement interface provides three methods: addBatch(), clearBatch() and executeBatch(). Their documentation is pretty straight forward. The implementation of these methods is optional, so be sure that your driver supports these.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123