• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Storing multiple query string and execute them using result set

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What benefit are you trying to gain by executing these statements later? I'm not sure I understand what you are aiming to do.
 
Rajubhai Kotwal
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, so its not the queries you need to store, it is the result of those queries?

 
Rajubhai Kotwal
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Paul.

Yes. Any suggestion? Thank you.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Paul

Thank you.
 
I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic