Accessing Data : Setting connection properties when a report runs : Setting the database user name and password at run time : How to enable a user to provide a database user name and password when a report runs
 
How to enable a user to provide a database user name and password when a report runs
This procedure assumes that you have already created a JDBC data source.
1 Create a report parameter to get the user name, using the following steps:
1 In Data Explorer, right-click Report Parameters, then choose New Parameter.
2 In New Parameter, supply the following information:
*In Name, type a name for the report parameter. For example:
username_param
*In Prompt text, specify a word or sentence to prompt the report user to provide a user name value. For example:
User name
*In Data type, select String.
Figure 4‑77 shows the completed report parameter definition.
Figure 4‑77 Report parameter to get the user name
3 Choose OK. The username_param parameter appears under Report Parameters in Data Explorer.
2 Use the previous steps to create a report parameter to get the password. Use the following values to define the report parameter:
*In Name, type
password_param
*In Prompt text, type
Password
*In Data type, select String.
3 Choose OK. The password_param parameter appears under Report Parameters in Data Explorer.
4 Bind the user name property to the username_param report parameter.
1 In Data explorer, right-click the JDBC data source, then choose Edit.
2 In Edit Data Source, choose Property Binding. The Property Binding page displays the JDBC connection properties.
3 Choose the expression builder button on the right of User Name.
4 In the expression builder, perform the following tasks:
*Under Category, choose Report parameters. All appears under Sub‑Category.
*Choose All. Under Double Click to insert, BIRT Report Designer displays the report parameters that you created.
*Double-click the username_param report parameter. The expression params["username_param"].value appears in the text area, as shown in Figure 4‑78.
Figure 4‑78 Choosing the username_param in the expression builder
*Choose OK. The expression builder closes. The report parameter expression appears in the User Name field, as shown in Figure 4‑79.
Figure 4‑79 User Name property bound to the username_param report parameter
5 Using the previous steps, bind the password property to the password_param report parameter.
5 In Edit Data Source, choose OK.
6 Preview the report to confirm that the user is prompted for a user name and password. Figure 4‑80 shows Enter Parameters, the dialog that prompts the user to enter a user name and password.
Figure 4‑80 Enter Parameters prompts the user for a user name and password
The values that the user specifies are used to connect to the JDBC database.