wood burning stoves 2.0*
The moose likes JDBC and the fly likes jdbc batch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc batch" Watch "jdbc batch" New topic
Author

jdbc batch

avijit majumder
Greenhorn

Joined: Sep 01, 2009
Posts: 15
How can I make multiple select Query in a batch

String st1="select password from login where id='"+1+"'";
String st2="select password from login where id='"+2+"'";

java.sql.Connection con=..............;
java.sql.Statement st=con.createStatement();
st.addBatch(st1);
st.addBatch(st2);
java.sql.ResultSet rs=st.executeBatch(); // BUT it return an int Array. int a[]=st.executeBatch();
/*
Now how can I find the RESULT in my ResultSet rs???
pl z help!!!

*/
Jaydeep Mazumdar
Greenhorn

Joined: Aug 26, 2009
Posts: 23
Please use tags to post code.

In your case, you can change the SQL to:



That way you will avoid invoking multiple sql statements in a batch.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Avjit,

Welcome to Javaranch

Now how can I find the RESULT in my ResultSet rs???
pl z help!!!


Why do you need a result Set for Batch ? Usually Batch is used to execute series of insert/update/delete statements pertaining to a single transaction.Either you commit at end or rollback on failure. Thus making it behave as single transaction.
Result Set object maintains cursor to navigate in the records fetched from DB. Its not useful in updateBatch case.
manepalli rajesh
Greenhorn

Joined: Oct 19, 2008
Posts: 15
Hi ,
our requirement is
we have a list of mailids in oracle table. we want to read all the mailids and wants to send a mail to them (i have a code to send mails). but this should be happen on daily basis.i dont know how to do this.can somebody help me in this.

ton of thanks.



Sivaraman Lakshmanan
Ranch Hand

Joined: Aug 02, 2003
Posts: 231
Hi Rajesh,
Just query your database for the email ids something like "Select * from emailtable where conditon". Once you execute the above statement you get the resultset. Loop through the resultset and get all the emails ids and store them in a StringBuffer seperated by ";". Then use this in your mailer programme.

Hope this helps.


Regards,
Sivaraman.L
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41601
    
  55
manepalli rajesh,

in the future, please do not post unrelated questions into an existing topic. Your question has nothing to do with the original topic, and we now have a discussion that deals with two unrelated issues, which is something we try hard to avoid.


Ping & DNS - my free Android networking tools app
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Jaydeep Mazumdar wrote:Please use tags to post code.

In your case, you can change the SQL to:



That way you will avoid invoking multiple sql statements in a batch.

Just be aware of that Oracle has a max param limit of 1000 in each IN clause...


Regards, Rene Larsen
Dropbox Invite
 
 
subject: jdbc batch