Home » Developer & Programmer » JDeveloper, Java & XML » Batch Execute of Insert Scripts
Batch Execute of Insert Scripts [message #91459] Wed, 18 September 2002 03:16 Go to next message
jack
Messages: 123
Registered: September 2000
Senior Member
I am using oracle 7.3.4 and the oracle driver classes111.zip
How can I have a batch of Insert statements to be executed in one shot. Ie say if I have some n rows to be inserted How can insert some m rows instead of inserting one at a time.
Re: Batch Execute of Insert Scripts [message #91473 is a reply to message #91459] Fri, 27 September 2002 09:20 Go to previous message
Amit Chauhan
Messages: 74
Registered: July 1999
Member
Hi,
You will have to use preparedStatement's addBatch and executeBatch methods. You can eaily find examples on google.
It will look something like this :
PreparedStatement ps = conn.prepareStatement (mySql);
ps.clearBatch ();

ps.setString ('a');
ps.setInt (1);

ps.addBatch ();

ps.setString ('b');
ps.setInt (2);

ps.addBatch ();

ps.setString ('c');
ps.setInt (3);

ps.addBatch ();

ps.executeBatch ();

ps.close ();


Hope that helps.
Thanks
Amit
Previous Topic: Re: sample test questions for OCP exams IZO-501/502/504/505
Next Topic: Migrate Forms/Reports to Java
Goto Forum:
  


Current Time: Fri Mar 29 01:51:53 CDT 2024