I need to run a piece of Java code which builds a complex SQL query. I know how to call the Java methods from JavaScript in BIRT but how can I get a pointer to the cu开发者_StackOverflow中文版rrent DB session/connection?
If you modify the onCreate event of your Data Set, you can do this on the report and leave BIRT to control the DB connection. Do the following:
- Select your Data Set on the Data Explorer window
- Select the scripts tab along the lower edge of the canvas area of Eclipse
- Select the "
onCreate
" event from the drop-down list of available events along the top - Work your query-building magic in the editor, using JavScript. You can import your existing POJO that build your query out using the "Packages" construct.
- Once your POJO has built the query, return it to the script and set "
this.queryText
" equal to the resulting string.
This will ensure the data set executes the new query, not the one used to create the data set.
The only gotcha to watch out for is that the query you set in the script must return the same number of columns and have each column be named the same as in the default configuration and share the same data type. How the individual colums get populated is up to the SQL, how the resulting data set looks must me uniform.
Good Luck!
精彩评论