我正在开发一个可以打开使用Crystal Reports生成的报表的Web应用程序。我已经关注了有关如何配置连接的其他帖子:
final Tables tablas = databaseController.getDatabase().getTables();
for (final ITable table : tablas) {
ITable t = (ITable)table.clone(true);
t.setQualifiedName(conexionBaseDatos.getIdentificadorNombreTabla() + table.getName());
final IConnectionInfo connectionInfo = table.getConnectionInfo();
final PropertyBag propertyBag = new PropertyBag();
propertyBag.put(TRUSTED_CONNECTION, "false");
propertyBag.put(SERVER_TYPE, "JDBC (JNDI)");
propertyBag.put(USE_JDBC, "true");
propertyBag.put(DATABASE_DLL, "crdb_jdbc.dll");
propertyBag.put(JNDI_OPTIONAL_NAME, conexionBaseDatos.getName());
propertyBag.put(CONNECTION_URL, conexionBaseDatos.getUri());
propertyBag.put(DATABASE_CLASS_NAME, conexionBaseDatos.getDriver());
connectionInfo.setAttributes(propertyBag);
connectionInfo.setUserName(conexionBaseDatos.getUser());
connectionInfo.setPassword(conexionBaseDatos.getPass());
connectionInfo.setKind(ConnectionInfoKind.SQL);
t.setConnectionInfo(connectionInfo);
try {
databaseController.setTableLocation(table, t);
} catch (final Exception e) {
LOGGER.error("Error.", e);
throw new ErrorGenerarInformeException(e);
}
}
我认为一切都是对的,但是控制台正在向我显示下一个错误:
2017-06-08 19:16:12,863 ERROR com.crystaldecisions.reports.dataengine.DataSourceManager.do(SourceFile:691) - Formula error: recompile formulas failed
com.crystaldecisions.reports.formulas.FormulaException: Exception in formula '{@PGAEJE}' en '{PGA.PGA_EJE}':
This field name is unknown.
at com.crystaldecisions.reports.formulas.o.a(SourceFile:1041)
at com.crystaldecisions.reports.formulas.o.do(SourceFile:1013)
at com.crystaldecisions.reports.formulas.o.new(SourceFile:688)
at com.crystaldecisions.reports.formulas.o.else(SourceFile:459)
at com.crystaldecisions.reports.formulas.f.void(SourceFile:65)
at com.crystaldecisions.reports.formulas.FormulaParser.a(SourceFile:345)
at com.crystaldecisions.reports.formulas.r.a(SourceFile:89)
at com.crystaldecisions.reports.formulas.FormulaInfo.a(SourceFile:570)
at com.crystaldecisions.reports.formulas.FormulaService.compile(SourceFile:347)
at com.crystaldecisions.reports.reportdefinition.FormulaCompiler.a(SourceFile:139)
at com.crystaldecisions.reports.reportdefinition.FormulaFieldDefinitionBase.compile(SourceFile:928)
at com.crystaldecisions.reports.reportdefinition.o.a(SourceFile:1360)
at com.crystaldecisions.reports.reportdefinition.o.a(SourceFile:1348)
at com.crystaldecisions.reports.reportdefinition.o.a(SourceFile:4253)
at com.crystaldecisions.reports.dataengine.DataSourceManager.do(SourceFile:687)
at com.crystaldecisions.reports.dataengine.DataSourceManager.new(SourceFile:607)
at com.crystaldecisions.reports.dataengine.DataSourceManagerCoordinator.a(SourceFile:505)
2017-06-08 19:16:47,473 INFO com.businessobjects.reports.sdk.JRCCommunicationAdapter.if(SourceFile:630) - received request: closeServerAgent
2017-06-08 19:16:47,473 INFO com.businessobjects.reports.sdk.JRCCommunicationAdapter.do(SourceFile:2619) - has cleaned up and closed down the report
2017-06-08 19:16:47,474 INFO com.crystaldecisions.reports.queryengine.Connection.ux(SourceFile:1883) - Connection logoffServer:
2017-06-08 19:16:47,493 INFO com.crystaldecisions.reports.queryengine.driverImpl.jdbc.JDBCConnection.Close(?:?) - Connection Closed !oracle.jdbc.driver.OracleDriver!jdbc:oracle:thin:{userid}/{password}@xxx
2017-06-08 19:16:47,648 ERROR org.slf4j.impl.Log4jLoggerAdapter.error(Log4jLoggerAdapter.java:571) - Failed to load the resource 'InternalFormatterException' from the bundle java.util.PropertyResourceBundle@1bd9a874.
java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key InternalFormatterException
at java.util.ResourceBundle.getObject(ResourceBundle.java:450)
at java.util.ResourceBundle.getObject(ResourceBundle.java:444)
at java.util.ResourceBundle.getString(ResourceBundle.java:407)
at com.crystaldecisions.reports.common.CrystalResources.loadString(Unknown Source)
at com.crystaldecisions.reports.common.CrystalResources.loadMessage(Unknown Source)
at com.crystaldecisions.reports.common.CrystalResourcesFactory.getLocalizedMessage(Unknown Source)
at com.crystaldecisions.reports.common.CrystalException.getLocalizedMessage(Unknown Source)
at com.crystaldecisions.reports.common.CrystalException.getMessage(Unknown Source)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
Caused by: com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: InternalFormatterException---- Error code:-2147467259 Error code name:failed
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.if(SourceFile:237)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:147)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:128)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:111)
Caused by: com.crystaldecisions.reports.dataengine.DataEngineException: Exception in formula '{@PGAEJE}' en '{PGA.PGA_EJE}':
This field name is unknown.
at com.crystaldecisions.reports.dataengine.DataSourceManager.do(SourceFile:692)
at com.crystaldecisions.reports.dataengine.DataSourceManager.new(SourceFile:607)
at com.crystaldecisions.reports.dataengine.DataSourceManagerCoordinator.a(SourceFile:505)
at com.crystaldecisions.reports.dataengine.DataSourceManager.a(SourceFile:1060)
at com.crystaldecisions.reports.dataengine.DataProcessor2.a(SourceFile:729)
at com.crystaldecisions.reports.formatter.formatter.objectformatter.ObjectFormatter.<init>(SourceFile:179)
at com.crystaldecisions.reports.formatter.formatter.objectformatter.ObjectFormatter.if(SourceFile:135)
at com.crystaldecisions.reports.formatter.formatter.paginator.PageFormatterBase.<init>(SourceFile:75)
at com.crystaldecisions.reports.formatter.formatter.paginator.PageFormatter.<init>(SourceFile:183)
at com.crystaldecisions.reports.formatter.formatter.paginator.PageFormatter.a(SourceFile:162)
at com.crystaldecisions.reports.formatter.export2.a.a(SourceFile:201)
... 153 more
我只是想将数据库中的字段绘制到报告中。当然报告的字段格式正确。我也有这个痕迹
2017-06-08 18:53:52,460 INFO com.crystaldecisions.reports.queryengine.driverImpl.jdbc.JDBCConnection.Open(?:?) - Connection Opened null
2017-06-08 18:53:52,470 INFO com.crystaldecisions.reports.queryengine.Connection.br(SourceFile:1856) - Connection logon successfully
我需要帮助。
编辑:我认为问题不在于连接
2017-06-08 20:19:32,630 INFO com.businessobjects.reports.sdk.JRCCommunicationAdapter.if(SourceFile:630) - received request: fetchSubreportNames
2017-06-08 20:20:43,604 INFO com.businessobjects.reports.sdk.JRCCommunicationAdapter.if(SourceFile:630) - received request: fetchReportExportRequest
2017-06-08 20:20:43,605 INFO com.businessobjects.reports.sdk.JRCLicenseThrottler.a(SourceFile:137) - attempting to send engine request
2017-06-08 20:20:43,605 INFO com.businessobjects.reports.sdk.JRCLicenseThrottler.a(SourceFile:142) - successfully sent engine request
2017-06-08 20:20:43,607 INFO com.crystaldecisions.reports.formulas.r.a(SourceFile:104) - Formula {@GRUPO} did not compile: com.crystaldecisions.reports.formulas.FormulaException: Exceptión in fórmula '{@GRUPO}' en '{PGA.PGA_EJE}':
This field name is not known.
2017-06-08 20:20:43,608 INFO com.crystaldecisions.reports.formulas.r.a(SourceFile:104) - Formula {@GRUPO} did not compile: com.crystaldecisions.reports.formulas.FormulaException: Exceptión in fórmula '{@GRUPO}' en '{PGA.PGA_EJE}':
This field name is not known.
2017-06-08 20:20:43,608 INFO com.crystaldecisions.reports.formulas.r.a(SourceFile:104) - Formula {@PGAECO} did not compile: com.crystaldecisions.reports.formulas.FormulaException: Exceptión in fórmula '{@PGAECO}' en '{PGA.PGA_ECO}':
This field name is not known.
2017-06-08 20:20:43,609 INFO com.crystaldecisions.reports.formulas.r.a(SourceFile:104) - Formula {@PGAFUN} did not compile: com.crystaldecisions.reports.formulas.FormulaException: Exceptión in fórmula '{@PGAFUN}' en '{PGA.PGA_FUN}':
This field name is not known.
2017-06-08 20:20:43,609 INFO com.crystaldecisions.reports.formulas.r.a(SourceFile:104) - Formula {@PGAORG} did not compile: com.crystaldecisions.reports.formulas.FormulaException: Exceptión in fórmula '{@PGAORG}' en '{PGA.PGA_ORG}':
This field name is not known.
2017-06-08 20:20:43,610 INFO com.crystaldecisions.reports.dataengine.DataSourceManager.z(SourceFile:3042) - Create new report state
2017-06-08 20:20:43,610 INFO com.crystaldecisions.reports.dataengine.DataSourceManager.do(SourceFile:679) - Need to recompile formulas, the number of formulas needed to recompile is 5
2017-06-08 20:20:43,611 INFO com.crystaldecisions.reports.formulas.r.a(SourceFile:104) - Formula {@PGAORG} did not compile: com.crystaldecisions.reports.formulas.FormulaException: Exceptión in fórmula '{@PGAORG}' en '{PGA.PGA_ORG}':
This field name is not known.
2017-06-08 20:20:43,611 WARN com.crystaldecisions.reports.reportdefinition.o.a(SourceFile:1366) - com.crystaldecisions.reports.formulas.FormulaException: Excepción en la fórmula '{@PGAORG}' en '{PGA.PGA_ORG}':
This field name is not known.
2017-06-08 20:20:43,611 ERROR com.crystaldecisions.reports.dataengine.DataSourceManager.do(SourceFile:691) - Formula error: recompile formulas failed
com.crystaldecisions.reports.formulas.FormulaException: Exception in formula '{@PGAEJE}' en '{PGA.PGA_EJE}':
This field name is not known.
at com.crystaldecisions.reports.formulas.o.a(SourceFile:1041)
at com.crystaldecisions.reports.formulas.o.do(SourceFile:1013)
at com.crystaldecisions.reports.formulas.o.new(SourceFile:688)
答案 0 :(得分:0)
最后,我在这一行解决了我的问题:
t.setQualifiedName(conexionBaseDatos.getIdentificadorNombreTabla() + table.getName());
函数getIdentifacadorNombreTable返回null,因此报告设置了nullName,如name。我设置了这个变量,知道工作正常。