Jump to content
Changes to the Jaspersoft community edition download ×

How to get a value from the database


patricksand

Recommended Posts

Folks, I have an interesting question: how do I get a value from the database outside of the report query? In particular, how can I do this, using the same db connection before the report query runs and get the value into a variable?

 

My first thought was to use an invisible subreport, but that doesn't appear to meet my needs (or I'm just clueless about using them).:dry:

 

My second thought is to use a scriptlet and embed some code in the beforeReportInit() method. But I would need to capture the connection object and feed my own query in, get the results, and set a variable (the last part is easy). :S

 

Any thoughts or experience? or clever suggestions?

 

I'm going to look through the source code and the examples, but any replies that can speed this up will be greatly appreciated.

 

Thanks in advance...

(hey, if nothing else I ask good questions, right? ;) )

Link to comment
Share on other sites

  • 4 weeks later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Perhaps you could use a parameter?

 

I don't know what interface you use to run your reports, but say you have an HTML or PHP page with a button to run the report - you could have the PHP page query the database and display the required record field in a textbox. You then pass the value as a variable in the URL string, then pick it up in a JSP page which runs the report's compile/fill/display. This variable would also be passed to the report, either to be simply displayed or to be used as a parameter to filter the report SQL query.

Link to comment
Share on other sites

Hi,

First You design your REport with the parameters in your Query or wherever you want it might be some where in your Report if you need..

Now Before you call your Jasper Code just Create a haspMap and pass that parameter value like this.

parameter.put(parameterInReport,"Hai");

 

Now while calling your Jasper Code send that HaspMap as a Parameter ..That will Resolve your Problem..

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...