Jump to content
Changes to the Jaspersoft community edition download ×

Defining Data Sources per Report Definition


madler

Recommended Posts

I have an application which utilizes multiple data sources. The application is essentially a "Dashboard". There is a core application data store, which contains the data specific to the application, however there could be many other data sources used by the application to display data to the user. Although I know how to create definition files which will look at data contained within the application's own data store, it is impossible to determine ahead of time where these other data stores will be. Is it possible to specifiy a database connection string which is specific to a particular report definition file (e.g. for this report, this database is required, and this query is run on that database to retreive data for the report).

 

Please let me know!

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

You can use a custom report property for this:

Code:

<jasperReport ...>
<property name="db.connection.string" value="..."/>
...
</jasperReport>

 

When you fill the report, you would do something like

Code:
[code]
JasperReport report = ...;
String dbConnectionString = report.getProperty("db.connection.string"«»);
Connection connection = createConnection(dbConnectionString);
JasperPrint print = JasperFillManager.fillReport(report, params, connection);

 

HTH,

Lucian

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...