BIRT:如何从 JavaScript 访问当前的数据库连接/会话?

发布于 2024-09-26 22:22:34 字数 94 浏览 0 评论 0原文

我需要运行一段 Java 代码来构建复杂的 SQL 查询。我知道如何在 BIRT 中从 JavaScript 调用 Java 方法,但如何获取指向当前数据库会话/连接的指针?

I need to run a piece of Java code which builds a complex SQL query. I know how to call the Java methods from JavaScript in BIRT but how can I get a pointer to the current DB session/connection?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪都笑了 2024-10-03 22:22:34

如果修改数据集的 onCreate 事件,则可以在报表上执行此操作,并让 BIRT 来控制数据库连接。执行以下操作:

  1. 在“数据资源管理器”窗口中选择您的数据集
  2. 选择 Eclipse 画布区域下边缘的脚本选项卡
  3. 从可用事件的下拉列表中选择“onCreate”事件 使用 JavScript 在编辑器中发挥
  4. 您的查询构建魔力。您可以导入现有的 POJO,使用“Packages”构造构建查询。
  5. POJO 构建查询后,将其返回到脚本并将“this.queryText”设置为等于结果字符串。

这将确保数据集执行新查询,而不是用于创建数据集的查询。

唯一需要注意的问题是,您在脚本中设置的查询必须返回相同数量的列,并且每列的命名与默认配置中的名称相同,并且共享相同的数据类型。如何填充各个列取决于 SQL,结果数据集的外观必须统一。

祝你好运!

If you modify the onCreate event of your Data Set, you can do this on the report and leave BIRT to control the DB connection. Do the following:

  1. Select your Data Set on the Data Explorer window
  2. Select the scripts tab along the lower edge of the canvas area of Eclipse
  3. Select the "onCreate" event from the drop-down list of available events along the top
  4. Work your query-building magic in the editor, using JavScript. You can import your existing POJO that build your query out using the "Packages" construct.
  5. Once your POJO has built the query, return it to the script and set "this.queryText" equal to the resulting string.

This will ensure the data set executes the new query, not the one used to create the data set.

The only gotcha to watch out for is that the query you set in the script must return the same number of columns and have each column be named the same as in the default configuration and share the same data type. How the individual colums get populated is up to the SQL, how the resulting data set looks must me uniform.

Good Luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文