Locking queries

Normally in JReport Designer, queries are free to be shared among reports, which could increase the potential risk of being changed unexpectedly. When a query is shared by more than one report, it can be changed by any of those reports, which means you must be very careful to avoid causing impacts to other reports when you modify the shared query for one report. However, JReport provides you with the flexibility to lock a query to prevent it from being changed by unauthorized person.

Creating a user to a query

Before you can lock or share a query, you need to claim the query by creating a user to it.

To creating a user to a query:

  1. Right-click the query you want to claim and select Create User from the shortcut menu.
  2. In the Create Query's Username and Password dialog, type in the user name and password.
  3. Click OK to confirm the information.

When a user has been created for a query, you can modify the user information or remove the user as required.

Note: A query can be claimed by only one user, that is to say, you can create only one user to a query.

Locking or sharing a query

Using the Share property of a query, you can lock or unlock it according to your requirements. By default, the Share property of a query is true, which means that all queries in a catalog can be shared among multiple reports, until you lock them.

To lock or unlock a query:

  1. Select the query that you want to lock or unlock.
  2. Click the Expand button on the Catalog Browser toolbar to show the Properties sheet.
  3. Locate the Share property and set its property to true or false. If it is true, the query can be shared among reports and can be modified. Otherwise, the query is locked and can be neither used in new reports nor modified by unauthorized person.

    Make sure that you have enabled the editable mode for the Properties sheet before editing the property values, that is to say, you have unchecked the option "Forbid editing data object properties" in the Options dialog.

You can also lock or unlock a query in the following way:

  1. Right-click the query that has already been claimed by a user and select Set Share Property from the shortcut menu.
  2. In the Set Query's Share Property dialog, provide the user information and check or clear the Share option as required.
  3. Click OK to confirm the change.

Notes: