I have this code
import com.crystaldecisions.reports.sdk.ReportClientDocument;
...
ReportClientDocument rpt = new ReportClientDocument();
rpt.open(reportPath+fileName, 0);
rpt.getDatabaseController().logon(DBConnect.getUsername(), DBConnect.getPassword());
Tables tables = rpt.getDatabaseController().getDatabase().getTables();
for(int i=0; i< tables.size(); i++){
System.out.print(i);
ITable table = tables.getTable(i);
IConnectionInfo connInfo = table.getConnectionInfo();
PropertyBag innerProp = connInfo.getAttributes();
innerProp.clear();
PropertyBag propertyBag = new PropertyBag();
propertyBag.put("Server Type", "JDBC (JNDI)");
propertyBag.put("Database DLL", "crdb_jdbc.dll");
propertyBag.put("Connection String", DBConnect.getConnectionString());
propertyBag.put("Database Class Name", "com.mysql.jdbc.Driver");
propertyBag.put("Use JDBC", "true");
propertyBag.put("Server Name", DBConnect.getServer());
propertyBag.put("Generic JDBC Driver Behavior", "No");
propertyBag.put("URI", "!com.mysql.jdbc.Driver!jdbc:mysql://"+DBConnect.getServer()+":"+DBConnect.getPort()+"/"+DBConnect.getDatabase()+"!ServerType=29!QuoteChar=`");
connInfo.setAttributes(propertyBag);
connInfo.setKind(ConnectionInfoKind.SQL);
table.setConnectionInfo(connInfo);
rpt.getDatabaseController().setTableLocation(table, tables.getTable(i));
What Im trying to do is to open a report and pass the connection info to that report so that I can dynamically change the database of the report but for some reason it is not working and the report still produces the information from the database that it was initially set up. Can someone please tell me what I did wrong? This is a swing application and I am using crystal reports XI. Btw Im using com.crystaldecisions.reports.sdk.ReportClientDocument instead of com.crystaldecisions.sdk.occa.report.application.ReportClientDocument because when I use the other one, I get a cannot find server error. Please help.