Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing multiple query string and execute them using result set

 
Rajubhai Kotwal
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.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate 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
Eclipse IDE Hibernate 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
Eclipse IDE Hibernate 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic