US and Worldwide: +1 (866) 660-7555
Results 1 to 4 of 4

Thread: Dynamic database connection

  1. #1

    Default Dynamic database connection

    Hi,

    Is it possible to set dynamically a database connection with a report parameter ?

    For example, choosing the database name with a drop down (String parameter) and setting dynamically the JDBC connection ?

    Thanks

  2. #2
    Join Date
    Nov 2005
    Posts
    164

    Default

    Yes.

    1. Create two queries.
    2. Create another query to hold the list of possible queries. For example, I created a table data source to hold query names.
    3. Create a parameter. The query for the parameter should be the query from step two above.
    4. On the Structure tab, select Master Report.
    5. Select the Attributes tab.
    6. For query > name, select the Expression button (+).
    7. In the Edit Expression dialog, add the following:

    =[myQuery]

    Where myQuery is the name of the parameter that you created in step three above.

  3. #3

    Default

    Hi

    Thank you very much !
    It's not exactly my use case (i have 2 different database connections, but queries are the same; i only want to parameter the database host name)

    But your method is a good way to do

    I've found another one => using a kettle datasource, and passing hostname as a drop down parameter from PRD (in PDI, host and database names accept ${} syntax )

  4. #4
    Join Date
    Mar 2003
    Posts
    7,557

    Default

    Of course, if you use PRD-3.9, then you have the full power of the scripting API at your hands. In the "init()" method you have access to the datafactory instance *before* it has been used. So you can reconfigure the connection (as long as you stick to the same type (JNDI to JNDI, or manual connection to manual connection)) using the parameter that come in.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •