File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Storing multiple query string and execute them using result set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Storing multiple query string and execute them using result set " Watch "Storing multiple query string and execute them using result set " New topic
Author

Storing multiple query string and execute them using result set

Rajubhai Kotwal
Ranch Hand

Joined: Nov 03, 2009
Posts: 47
Experts,

I have been working on jasper report. I am trying to execute the report within a java file. In order to do this, I need to execute sql statement within java. I wish to know how we can store multiple sql statements and execute them later? I have 3 statements to be executed. "select COUNT(*) from employee", "select COUNT(*) from employer" and "select COUNT(*) from company" How should I amend my code in order to execute all 3 queries? How should I map the stored data? Please suggest/help. Following is my code. Thank you.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What benefit are you trying to gain by executing these statements later? I'm not sure I understand what you are aiming to do.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Rajubhai Kotwal
Ranch Hand

Joined: Nov 03, 2009
Posts: 47
@Paul

Thank you for responding to the topic. I am generating a report of the records using ireport. It is not possible to use multiple select queries in ireport. Therefore, I need to use java in order to execute those queries. I am trying to get the counts of the tables initially and later I wish to crosscheck them while exporting data to the destined table. For e.g if i delete some records from a table. Then those counts should explain that how many record counts were deleted. In order to execute those queries, i need to store them in a set. Here I am little confused; how to do that? Thank you.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Ah, so its not the queries you need to store, it is the result of those queries?

Rajubhai Kotwal
Ranch Hand

Joined: Nov 03, 2009
Posts: 47
@Paul.

Yes. Any suggestion? Thank you.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

All you need to do it loop through the ResultSets and add their contents to a Collection. Not much more to it really.
Rajubhai Kotwal
Ranch Hand

Joined: Nov 03, 2009
Posts: 47
@Paul

Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing multiple query string and execute them using result set