You can use script to solve the first problem.
You can define a parameter to specify the path to the properties file, and then create a datasource.
Edit the Beforeopen event in DataSource script, referring 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 ();
This allows you to dynamically read data source configuration information from the properties file.
--------------------------------------------------------------------------------------------------------------- -You can write the configuration file dead in the code, or you can define the report parameters, please note params["Propfile"] here.
The code here only supports absolute paths, which may not be appropriate in the case of deployment, and can be modified to support relative paths relative to the application root directory you publish.
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"));
}