Switching report database connection in URL
To access reports via URL, you can switch the connection in the same database or between different databases at runtime. As a result, if the databases you want to switch between have the same structure, you will then be free from having to build another similar catalog. You can use the switch database commands to set the JDBC connection or to change the user name/password in order to connect to another database.
The following are database connection commands:
- jrs.jdbc_url
Constant: jet.cs.util.APIConst.TAG_JDBC_URL
Description: Specifies the new JDBC URL in the catalog to run a report.
- jrs.jdbc_driver
Constant: jet.cs.util.APIConst.TAG_JDBC_DRIVER
Description: Specifies the new JDBC driver in the catalog to run a report.
- jrs.db_user
Constant: jet.cs.util.APIConst.TAG_DB_USER
Description: Specifies the new database user ID.
- jrs.db_pswd
Constant: jet.cs.util.APIConst.TAG_DB_PSWD
Description: Specifies the new database password.
When connecting to a different database with different database metadata or data metadata, you need to also specify the following commands to set the target database metadata information if there are differences:
- jrs.db_refresh_support_info
Constant: TAG_DS_REFRESH_SUPPORT_INFO
Description: Optional. If it is true, JReport will get support information including reverse words, quote characters, and so on from the driver each time fetching data from the database. If it is not set, the property will be treated as false. It is recommended that you set this property to true when connecting to a different database.
- jrs.db_quote_character
Constant: TAG_DS_QUOTE_CHARACTER
Description: Optional. Specifies the quote characters.
- jrs.db_extra_characters
Constant: TAG_DS_EXTRA_CHARACTERS
Description: Optional. Specifies the extra characters.
- jrs.db_date_format
Constant: TAG_DS_DATE_FORMAT
Description: Optional. Specifies the date format.
- jrs.db_datetime_format
Constant: TAG_DS_DATETIME_FORMAT
Description: Optional. Specifies the datetime format.
- jrs.db_time_format
Constant: TAG_DS_TIME_FORMAT
Description: Optional. Specifies the time format.
- jrs.db_transaction_readonly
Constant: TAG_DS_TRANSACTION_READONLY
Description: Optional. Specifies the transaction "read only" property. Possible value: "default", "Read only", or "Read&Write". Ignore other values.
- jrs.db_transaction_mode
Constant: TAG_DS_TRANSACTION_MODE
Description: Optional. Specifies the transaction mode. Possible value: "default", "None", "Read Uncommitted", "Read Committed", "Repeatable Read", or "Serializable". Ignore other values.
- jrs.db_char_to_be_replaced
Constant: TAG_DS_CHAR_TO_BE_REPLACED
Description: Optional. Specifies the characters that are to be replaced.
- jrs.db_char_replaced_by
Constant: TAG_DS_CHAR_REPLACED_BY
Description: Optional. Specifies the characters used to replace the characters specified by jrs.db_char_to_be_replaced.
Switching the connection and user/password in the same database
- Set the Oracle database named oracle815 connection when designing the report Report1.cls, and later switch the connection to the Oracle database named demo at runtime.
The URL for switching the connection:
http://localhost:8888/jrserver/SampleReports.cat/Report1.cls?jrs.cmd=jrs.try_vw&jrs.result_type=1&jrs.jdbc_url=jdbc:oracle:thin:@host:1521:demo
- Set the SQL database named MBA2000 when designing the report Report1.cls, and later switch the connection to the SQL database named JTTest at runtime.
The URL for switching the connection:
http://localhost:8888/jrserver/SampleReports.cat/Report1.cls?jrs.cmd=jrs.try_vw&jrs.result_type=1&jrs.jdbc_url=jdbc:inetdae:host:1433?database=JTTest&sql7=true
- Specify the user ID system/manager to ensure security when designing the web report Report2.wls, and then switch to the user ID Scott and the password tiger when running the report in Web Report Studio.
The URL for switching the user ID and password:
http://localhost:8888/jinfonet/tryView.jsp?jrs.cmd=jrs.try_vw&jrs.report=/Report2.wls&jrs.catalog=/SampleReports.cat&jrs.result_type=8&jrs.db_user=Scott&jrs.db_pswd=tiger
- Set the Sybase 12 database named master when designing the web report Report2.wls, and later switch the connection to the Sybase 12 database named product at runtime.
The URL for switching the connection:
http://localhost:8888/jrserver/SampleReports.cat/Report2.wls?jrs.cmd=jrs.try_vw&jrs.result_type=1&jrs.jdbc_url=jdbc:sybase:Tds:host:5000/product
Switching the connection between different databases with the same database metadata
- Set oracle815 connection when designing the report Report1.cls, and then switch the connection to Access database with the JDBC-ODBC driver named products at runtime.
The URL for switching the connection:
http://localhost:8888/jrserver/SampleReports.cat/Report1.cls?jrs.cmd=jrs.try_vw&jrs.result_type=1&jrs.jdbc_driver=sun.jdbc.odbc.JdbcOdbcDriver&jrs.jdbc_url=jdbc:odbc:products
- Set oracle815 connection when designing the web report Report2.wls, and then switch the connection to SQL server database named products at runtime.
The URL for switching the connection:
http://localhost:8888/jrserver/SampleReports.cat/Report2.wls?jrs.cmd=jrs.try_vw&jrs.result_type=1&jrs.jdbc_driver=com.inet.tds.TdsDriver&jrs.jdbc_url=jdbc:inetdae:JT_P05:1433?database=products&sql7=true
Switching the connection between different databases with different database metadata
The URL for switching the database to Oracle when running the page report report1.cls:
http://localhost:8080/remote/sub/jinfonet/tryView.jsp?jrs.cmd=jrs.try_vw&jrs.catalog=/Test/Test.cat&jrs.report=/Test/report1.cls&jrs.result_type=8&jrs.jdbc_driver=oracle.jdbc.driver.OracleDriver&jrs.jdbc_url=jdbc:oracle:thin:@192.168.0.1:1521:oracle9&jrs.db_user=test&jrs.db_pswd=1234&jrs.db_quote_character="&jrs.db_date_format=M/d/yyyy&jrs.db_datetime_format=d/M/yyyy h:mm:ss a&jrs.db_time_format=HH:mm:ss.SSS&jrs.db_transaction_readonly=Read Only&jrs.db_transaction_mode=Repeatable Read&jrs.db_char_to_be_replaced=}&jrs.db_char_replaced_by=}oracle91234
Related topics: