【问题标题】:Pass Oracle connection to BIRT report将 Oracle 连接传递给 BIRT 报告
【发布时间】:2015-06-29 13:08:32
【问题描述】:

我创建了一个使用 DB(在我的例子中是 Oracle DB)的 BIRT 报告模板。 查询是这样的:

SELECT Something, Quantity FROM SOMETABLE WHERE Like ?

从 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 但它并没有真正帮助我,我不确定我是否了解 cmets。

有人可以帮我吗?代码示例会很好。

【问题讨论】:

    标签: java oracle jdbc birt


    【解决方案1】:

    好的,

    实际上这段代码似乎没有问题。我只是使用了一些错误版本的 BIRT (4.2.0)。更新到 4.4.1 后一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-31
      相关资源
      最近更新 更多