You can use scripts to solve the first problem.
You can define a parameter to specify the path of the properties file and then create a datasource.
Edit the beforeopen event in the datasource script. refer to the following code:
========================================================
Importpackage (packages. java. Io );
Importpackage (packages. java. util );
Fin = new java. Io. fileinputstream (new string (Params ["propfile"]);
Props = new java. util. properties ();
Props. Load (FIN );
Extensionproperties. odaurl = new string (props. getproperty ("url "));
Extensionproperties. odadriverclass = new string (props. getproperty ("driver "));
Extensionproperties. odauser = new string (props. getproperty ("userid "));
Extensionproperties. odapassword = new string (props. getproperty ("password "));
Fin. Close ();
In this way, the data source configuration information can be dynamically read from the properties file.
Bytes ----------------------------------------------------------------------------------------------------------------
You can write the configuration file in the code or define it as a report parameter. Note the following: Params ["propfile.
The code here only supports absolute paths, which may not be applicable in deployment. You can modify the supported relative paths relative to the application root directory you published.
Importpackage (packages. java. Io, packages. java. util, packages.java.net );
Importpackage (packages. javax. servlet. http );
Req = reportcontext. gethttpservletrequest ();
Proppath = new string (Params ["propfile"]);
If (proppath. charat (0 )! = "/")
Proppath = "/" + proppath;
Url = Req. getsession (). getservletcontext (). getresource (proppath );
If (URL! = NULL)
{
Props = new java. util. properties ();
Props. Load (URL. openstream ());
Extensionproperties. odaurl = new string (props. getproperty ("url "));
Extensionproperties. odadriverclass = new string (props. getproperty ("driver "));
Extensionproperties. odauser = new string (props. getproperty ("userid "));
Extensionproperties. odapassword = new string (props. getproperty ("password "));
}