Thursday, February 18, 2010

Re: [Java] JDBC executeBatch() method

 

It should be 3 requests. If the tables are in a parent/child relationship, you need to add the parent first.

An alternative: enclose the inserts in a transaction (begin/commit or rollback). That way, if somethig goes wrong you won't have a partially-correct database.

-Java Guy

-----Original Message-----

From: "sreekanth" <sreekanth.816@gmail.com>
Subj: [Java] JDBC executeBatch() method
Date: Thu Feb 18, 2010 1:36 pm
Size: 10K
To: Java_Official@yahoogroups.com

Hi all,
Statement stmt = con.createStatement();stmt.addBatch("insert into
first(...)");stmt.addBatch("insert into
second(...)");stmt.addBatch("insert into third(...)");
stmt.executeBatch();
I am using above code to insert data into 3 tables at a time.
When i call stmt.executeBatch(); method,Can any one tell me, whether 3
requests (calls) will go to database to insert data into tables or with
single request (call) data will insert into 3 tables?
Note: my application is in my system and database is at remote location.

[Non-text portions of this message have been removed]






__._,_.___
Visit http://aiaiai.com or http://jgame.org for more groups to join.
Java Official Group is created for the following topics: Java 2 Enterprise Edition - J2EE, Java 2 Standard Edition - J2SE, Java 2 Micro Edition - J2ME, XML, XSL, XSD, XPATH, Web Services, Jini, JXTA for all type of Java Geeks.
Whoever posts spam / ads / job related message will be BANNED IMMEDIATELY
.

__,_._,___

No comments:

Post a Comment