[英]BIRT: How can I access the current DB connections/session from JavaScript?
I need to run a piece of Java code which builds a complex SQL query. 我需要运行一段Java代码,以构建一个复杂的SQL查询。 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?
我知道如何从BIRT中的JavaScript调用Java方法,但是如何获得指向当前数据库会话/连接的指针?
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. 如果您修改数据集的onCreate事件,则可以在报表上执行此操作,并保留BIRT来控制数据库连接。 Do the following:
请执行下列操作:
onCreate
" event from the drop-down list of available events along the top onCreate
”事件 this.queryText
" equal to the resulting string. this.queryText
”等于结果字符串。 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.
如何填充各个列取决于SQL,结果数据集的外观必须统一。
Good Luck! 祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.