BIRT:如何从 JavaScript 访问当前的数据库连接/会话?
我需要运行一段 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果修改数据集的 onCreate 事件,则可以在报表上执行此操作,并让 BIRT 来控制数据库连接。执行以下操作:
onCreate
”事件 使用 JavScript 在编辑器中发挥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:
onCreate
" event from the drop-down list of available events along the topthis.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!