我有这段代码
我想做的是打开一个报告并传递连接信息到报告中,以便我可以动态更改报告的数据库,但出于某种原因它没有工作,报告仍然生成最初设置的数据库中的信息。请问有人能告诉我我做错了什么吗?这是一个swing应用程序,我正在使用Crystal Reports XI。顺便说一下,我正在使用com.crystaldecisions.reports.sdk.ReportClientDocument而不是com.crystaldecisions.sdk.occa.report.application.ReportClientDocument,因为当我使用另一个时,我会收到一个无法找到服务器错误。请帮忙。
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));
我想做的是打开一个报告并传递连接信息到报告中,以便我可以动态更改报告的数据库,但出于某种原因它没有工作,报告仍然生成最初设置的数据库中的信息。请问有人能告诉我我做错了什么吗?这是一个swing应用程序,我正在使用Crystal Reports XI。顺便说一下,我正在使用com.crystaldecisions.reports.sdk.ReportClientDocument而不是com.crystaldecisions.sdk.occa.report.application.ReportClientDocument,因为当我使用另一个时,我会收到一个无法找到服务器错误。请帮忙。