birt报告返回null

3bygqnnd  于 2021-06-30  发布在  Java
关注(0)|答案(1)|浏览(373)

birt报告可以使用硬编码的jdbc连接生成。但我得写20多份报告。但是当jdbc被移动到生产服务器时,所有报告中的jdbc url和凭证都必须更改,这有点麻烦。
因此,我想使用jndi数据源选项将所有内容保存在一个地方。如果创建了jndi数据源,那么像tomcat这样的容器就可以管理连接池等,我做了以下步骤来做到这一点,但它总是返回错误“JDBCURL为空”。
在bonita.xml中创建了jndi数据源 <Resource name="ds/businessdb" auth="Container" type="javax.sql.DataSource" maxActive="5" maxIdle="-1" maxWait="10000" username="root" password="password" driverClassName="com.mysql.cj.jdbc.Driver" url="jdbc:mysql://<ip>:3306/db"/> 在birt web应用程序的web.xml中添加了条目 <resource-ref> <description>Resource reference to a factory forjava.sql.Connection</description> <res-ref-name>ds/businessdb</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> 然后在birt报告设计中,我使用jndiurl作为
java:comp/env/ds/businessdb
它返回jdbc url为空。

7bsow1i6

7bsow1i61#

afaik,对于tomcat数据源,您需要
tomcat/server.xml中的条目 <Resource auth="Container" driverClassName="com.mysql.cj.jdbc.Driver" ... tomcat/context.xml中的条目 <ResourceLink type="javax.sql.DataSource" name=... 确保数据库驱动程序jar在运行时可用于服务器。
(我不知道什么是bonita.xml)
您还可以通过编写一个小型应用程序,向db发出一些请求,并在服务器上运行它来检查tomcat数据源是否配置正确。

相关问题