Hi,
I have a trivial request which cannot handle with CR4E: to use JNDI DataSource database connection on Web Server. This was mentioned and some pages here, but I didnu2019t find solution.
Request:
On design phase the customer will use local db connection. That works fine.
On run phase, the report is generation on web server and it need to change the db data source using JNDI data source stored on web server (letu2019s say, it is u201Cdbsourcenameu201D).
Database could be Sybase or Oracle, and maybe new one in future.
Currently Web Server is JBoss 4.2/4.3, but could be WebLogic.
Used API: com.crystaldecisions.sdk.occa.report
In short we need something like:
private static void setDatabaseConnection(ReportClientDocument reportClientDoc) throws ReportSDKException, NamingException {
DatabaseController dbController = reportClientDoc.getDatabaseController();
ConnectionInfos oldConInfos = dbController.getConnectionInfos(null);
for (int i = 0, size = oldConInfos.size(); i < size; i++) {
IConnectionInfo oldConnectionInfo = oldConInfos.getConnectionInfo(i);
HashMap properties = oldConnectionInfo.getAttributes();
String serverType = (String)properties.get("Server Type");
if (serverType.contains("JNDI") || serverType.contains("JDBC")) { // DB access, NOT POJO, Beans, XML
// dbController.setJNDIOptionalName(oldConnectionInfo, "dbsourcename"); - for internal use only
// or something via PropertyBag and dbController.replaceConnection
// or something as xxxx.setXXXXDataSourceXXXX( (DataSource) InitialContext().initialContext.lookup(u201Cu2026u201D) )
}
}
}
Or similar. The dp parameters need to be hidden on JNDI DataSource.
Iu2019m familiar with CR API (Iu2019m working with POJO approach on Web for a moths).
If there is no solution for JNDI approach, what is reasonable enterprise web solution alternative.
Please give concrete answer.
Thanks,
Dejan
Edited by: dejan.pavlovic on Nov 18, 2010 5:40 PM