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)
how to update DB after render the report
savinyqs
Hi,
I am trying to update DB after render report, but there is no idea to get connection and execute a update statement in "afterRender" method. is there any sample for this?
BTW, is there any solution to reuse a dataSource or dataSet after the report render? Or if I can create a new datasource or dataset during "afterRender" method?
Thanks & Best Regards,
Savin
Find more posts tagged with
Comments
mcremer
<blockquote class='ipsBlockquote' data-author="'savinyqs'" data-cid="84579" data-time="1319706518" data-date="27 October 2011 - 02:08 AM"><p>
Hi,<br />
<br />
I am trying to update DB after render report, but there is no idea to get connection and execute a update statement in "afterRender" method. is there any sample for this?<br />
<br />
BTW, is there any solution to reuse a dataSource or dataSet after the report render? Or if I can create a new datasource or dataset during "afterRender" method?<br />
<br />
Thanks & Best Regards,<br />
Savin<br /></p></blockquote>
Hi,<br />
<br />
The only way I can think up is to just create a script (using javascript and heavy usage of Java). To create a connection and execute your update statement as a JDBC conection to the databse.
savinyqs
<blockquote class='ipsBlockquote' data-author="'mcremer'" data-cid="84581" data-time="1319707762" data-date="27 October 2011 - 02:29 AM"><p>
Hi,<br />
<br />
The only way I can think up is to just create a script (using javascript and heavy usage of Java). To create a connection and execute your update statement as a JDBC conection to the databse.<br /></p></blockquote>
hi mcremer,<br />
<br />
Thanks for your quickly reply. I tried to use Java coding to new a connection, but it can't work since it throw the exception that "java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver"(I use DB2). Do u have any advice for this? Or any sample for create connection through javascript?<br />
<br />
Thanks & Best Regards,<br />
Savin
CBR
Had the same issue when trying to create a connection using javaScript. It is caused by classloader separation. So Rhino is using a different classloader to execute it's code. This classloader doesn't have access to the driver jar's causing class for name is not a good idea in Rhino.
I suggest to use a java eventhandler. So just implement all the logic in Java as you did in Rhino Script.
Have a look at that tutorial on how to create a java event handler in BIRT:
http://www.linuxtopia.org/online_books/eclipse_documentation/eclipse_birt_report_guide/topic/org.eclipse.birt.doc/birt/eclipse_birt_report_ScriptingWithJava.html
and on this blog post on how to tell BIRT that you have java code in a different project (only necessary if you are using BIRT 2.5.2 or later):
http://birtworld.blogspot.com/2009/12/birt-designer-classpath-changes.html