This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

jdbc batch

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!

*/
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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...
 
Wanna see my flashlight? How about this tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!