Quantcast
Channel: SCN : Popular Discussions - SAP Crystal Reports, version for Eclipse
Viewing all articles
Browse latest Browse all 893

Change database

$
0
0

Hello,

 

I'm using the Crystal Reports Java SDK from Crystal Reports for Eclipse 2.0 (normal Java code, no JSP) and trying to change the database during runtime. Here's my code snippet:

final PropertyBag newConnectionProperties = new PropertyBag();
final IConnectionInfo newConnectionInfo = new ConnectionInfo();
newConnectionProperties.put("Use JDBC", true);
newConnectionProperties.put("Connection URL", "jdbc:jtds:sybase://IP:PORT/DATABASE_NAME");
newConnectionProperties.put("Database Class Name", "net.sourceforge.jtds.jdbc.Driver");
newConnectionProperties.put("Database DLL", "crdb_jdbc.dll");
newConnectionInfo.setAttributes(newConnectionProperties);

try {
    newConnectionInfo.setUserName("USER_NAME");    newConnectionInfo.setPassword("PASSWORD");    final IConnectionInfo oldConnectionInfo = reportClientDocument.getDatabaseController().getConnectionInfos(null).getConnectionInfo(0);    reportClientDocument.getDatabaseController().replaceConnection(oldConnectionInfo, newConnectionInfo, null, 0);
}
catch (ReportSDKException exception) {
}

 

The problem is that Crystal Reports always connects to the database specified during design time in the report. Lets assume there are two databases on the same server: DATABASE_DEVELOPMENT and DATABASE_TEST. During design time, the report has been configured to connect to the development database. But during runtime, I'd like to connect to the test database (or maybe a production database). This does not work with the above code (assuming that the DATABASE_NAME in the connection URL is replaced with DATABASE_DEVELOPMENT or DATABASE_TEST). What am I doing wrong?

 

Thanks in Advance!

 

Robin Lebert


Viewing all articles
Browse latest Browse all 893

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>