我创建了一个使用DB的BIRT报告模板(在我的例子中是Oracle DB)。 查询如下:
从某些东西中选择某些东西,数量是多少?
从Eclipse(对于BIRT报告)一切正常。问题是我想创建一个能完成这项工作的Web服务。 所以我尝试传递连接,如:
Connection conn = null;
try {
DriverManager.registerDriver((Driver) Class.forName("oracle.jdbc.OracleDriver").newInstance());
conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:name","user","pass");
} catch (SQLException | InstantiationException | IllegalAccessException | ClassNotFoundException ex) {
// handle any errors
System.out.println("SQLException Message: " + ex.getMessage());
}
task.getAppContext().put("OdaJDBCDriverPassInConnection", conn);
task.getAppContext().put("OdaJDBCDriverPassInConnectionCloseAfterUse", false);
我得到了:
Caused by: org.eclipse.birt.data.engine.odaconsumer.OdaDataException: Failed to prepare the following query for the data set type (org.eclipse.birt.report.data.oda.jdbc.dbprofile.sqbDataSet).
[SELECT SOMETHING, QUANTITY FROM SOMETABLE WHERE SOMETHING LIKE ?
]
org.eclipse.datatools.connectivity.oda.consumer.helper.OdaHelperException: The established connection to the data source is not active.
at org.eclipse.birt.data.engine.odaconsumer.ExceptionHandler.newException(ExceptionHandler.java:54)
at org.eclipse.birt.data.engine.odaconsumer.ExceptionHandler.throwException(ExceptionHandler.java:108)
at org.eclipse.birt.data.engine.odaconsumer.Connection.prepareOdaQuery(Connection.java:298)
at org.eclipse.birt.data.engine.odaconsumer.Connection.prepareStatement(Connection.java:197)
at org.eclipse.birt.data.engine.executor.DataSource.prepareStatement(DataSource.java:302)
at org.eclipse.birt.data.engine.executor.DataSourceQuery.prepare(DataSourceQuery.java:281)
at org.eclipse.birt.data.engine.impl.PreparedOdaDSQuery$OdaDSQueryExecutor.prepareOdiQuery(PreparedOdaDSQuery.java:442)
at org.eclipse.birt.data.engine.impl.QueryExecutor.prepareExecution(QueryExecutor.java:341)
... 66 more
Caused by: org.eclipse.datatools.connectivity.oda.consumer.helper.OdaHelperException: The established connection to the data source is not active.
at org.eclipse.datatools.connectivity.oda.consumer.helper.OdaObject.newOdaException(OdaObject.java:548)
at org.eclipse.datatools.connectivity.oda.consumer.helper.OdaConnection.newQuery(OdaConnection.java:562)
at org.eclipse.birt.data.engine.odaconsumer.Connection.prepareOdaQuery(Connection.java:285)
... 71 more
我在网上发现的只有:https://bugs.eclipse.org/bugs/show_bug.cgi?id=360702但它并没有真正帮助我,我不确定我理解这些评论。
有人可以帮助我吗?代码示例很不错。
答案 0 :(得分:0)
确定,
实际上这个代码似乎没有问题。我刚刚使用了BIRT(4.2.0)的一些错误版本。更新到4.4.1后一切正常。