Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Using Supplied Database Connection in BIRT 2.6.1
karthikr
Hi, <br />
<br />
We were using BIRT Report Engine Version 2.3.2. We passed the Data Connection to BIRT using the combination of the Code Snippet Below<br />
<br />
task.setParameterValue("dbConn", getRepositoryConnection());<br />
<br />
and the below Code in the BIRT RPTDESIGN file <br />
<br />
var conn = params["dbConn"].value; <br />
reportContext.getAppContext().put("OdaJDBCDriverPassInConnection", conn);<br />
<br />
This was placed in the BeforeOpen method of the DataSource. <br />
<br />
We already have a copy of the Driver File in the target platform, so we did not place the Database Driver places under the plugin org.eclipse.birt.report.data.oda.jdbc<br />
<br />
This worked in BIRT 2.3.2 and we were also able to see the Generated Reports<br />
<br />
We migrated the same report to BIRT 2.6.1 and it forced us to make a change saying that the parameter dbConn should be of the type String so the Code changed as below<br />
<br />
task.setParameterValue("dbConn", getRepositoryConnection().toString());<br />
<br />
whereas the Code in the RPTDESIGN file remained the same as earlier. <br />
<br />
We did not copy the drivers under org.eclipse.birt.report.data.oda.jdbc folder in the target platform since these database Jars are already located in the target platform under a different folder. When we run the report, We get an error message like the below<br />
<strong class='bbc'><br />
Data (id = 15962):<br />
+ An exception occurred during processing. Please see the following message for details:<br />
Cannot open the connection for the driver: org.eclipse.birt.report.data.oda.jdbc.<br />
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Cannot load JDBC Driver class: com.ibm.db2.jcc.DB2Driver. </strong><br />
<br />
If I place the driver file under the report.data.oda.jdbc folder, then it works but can somebody suggest/advise as to why this might be the case. <br />
<br />
Why does it work in BIRT 2.3.2 while it throws error in BIRT 2.6.1 ? <br />
<br />
Any Insight /Suggestions would be very much appreciated. <br />
<br />
Thanks<br />
Karthik
Find more posts tagged with
Comments
JasonW
Why pass it as a parameter? If you are using the api just call:
task.getAppContext().put("OdaJDBCDriverPassInConnection", getRepositoryConnection());
Jason
karthikr
Hi Jason, <br />
<br />
Thanks for your quick reply. I will try doing this, but this will be really complicated since getRepositoryConnection() is a method of an instance which we are injecting using Spring Dependency Injection, Doing the same inside the BIRT Report would be very difficult. <br />
<br />
Would passing the connection as a parameter not work in BIRT 2.6.1. We had success in doing the same when we were using BIRT 2.3.2. Can you please let us know ? <br />
<br />
Thanks<br />
<br />
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="71869" data-time="1294153796" data-date="04 January 2011 - 08:09 AM"><p>
Why pass it as a parameter? If you are using the api just call:<br />
<br />
task.getAppContext().put("OdaJDBCDriverPassInConnection", getRepositoryConnection());<br />
<br />
Jason<br /></p></blockquote>
JasonW
Maybe if you serialized it and then base64 encoded it but I doubt it. With 2.6.1 object types are not supported as parameters.
If you are setting it like:
task.setParameterValue("dbConn", getRepositoryConnection().toString());
This method should be doable:
task.getAppContext().put("OdaJDBCDriverPassInConnection", getRepositoryConnection());
As this can be done on the same task. I am confused at why it does not work.
BTW I have done a couple blogpost on spring integration with BIRT. Not sure they will help in this situation but here they are:
http://birtworld.blogspot.com/2009/11/calling-spring-objects-from-birt.html
http://birtworld.blogspot.com/2009/11/more-on-birt-and-spring.html
http://birtworld.blogspot.com/2009/11/accessing-spring-beans-from-birt.html
Jason