Changing connection string dynamically in CR XI - Java
843838Jun 19 2006 — edited May 29 2009Am using CR XI and working on RPTs that are migrated to XI from 8.5 through the migration wizard in CR XI(Server).
The integration of CR with the application is done through Java.
I'm using ORACLE 9i as backend. (JDBC is used to connect CR to Oracle)
I am not able to change the connection string through the Java. I have given the code(JSP) that i have written to accomplish the same. Any help will be greatly appreciated.
String con_string;
con_string = "Use JDBC=b(true);Connection URL=s(jdbc:oracle:thin:@xyz:1521:pqr);Database Class Name=s(oracle.jdbc.driver.OracleDriver);JNDI Datasource Name=s();Server=s(pqr);User ID=s(uid);Password=;Trusted_Connection=b(false);JDBC Connection String=s(!oracle.jdbc.driver.OracleDriver!jdbc:oracle:thin:{userid}/{password}@xyz:1521:pqr!ServerType=27!QuoteChar=\");Generic JDBC Driver Behavior=s(No);PreQEServerType=s(JDBC (JNDI));DSN=s(pqr)";
String con_url;
con_url = "jdbc:oracle:thin:@xyz:1521:pqr";
String db_classname = "oracle.jdbc.driver.OracleDriver";
PropertyBag pbnew = new PropertyBag();
ConnectionInfo newci = new ConnectionInfo();
pbnew.put("User ID","uid");
pbnew.put("Connection URL",con_url);
pbnew.put("Database Classname",db_classname);
pbnew.put("Server Name","pqr");
pbnew.put("Connection String",con_string);
pbnew.put("Database DLL","crdb_jdbc.dll");
newci.setAttributes(pbnew);
newci.setUserName("uid");
newci.setPassword("pwd");
ConnectionInfos newconis=new ConnectionInfos();
newconis.add(newci);
.
.
.
oReportClientDocument.open(reportName, 0);
Object reportSource = oReportClientDocument.getReportSource();
oReportClientDocument.verifyDatabase();
CrystalReportViewer oCrystalReportViewer = new CrystalReportViewer();
oCrystalReportViewer.setReportSource(reportSource);
oCrystalReportViewer.setDatabaseLogonInfos(newconis);
.
.
.
oCrystalReportViewer.getHtmlContent(request, response, getServletConfig().getServletContext());
The code is not working even for a RPT that does not have a sub-report. I would like to know if the code is fine or some changes has to be made to it. It will be more helpful, if the solution includes details about changing the datasource for RPTs with sub-reports, too.