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 get existing and use existing report connection
wirzbicki
Greeting all,<br />
<br />
I have a need to use an existing report connection to gain access to global temporary tables that are create prior to the report executing. I need the same connection to gain access to the global temp tables so instead of doing a <strong class='bbc'>DataEngine.newDataEngine</strong> which works no GT table access. <br />
<br />
<br />
<strong class='bbc'>to create the db connections create a beforeFactory method with:</strong> <br />
reportContext.getAppContext().put("OdaJDBCDriverPassInConnection", conn);<br />
<br />
<strong class='bbc'>within the beforeFactory event in the report I do:</strong> <br />
var de = reportContext.getAppContext().get("OdaJDBCDriverPassInConnection"); <br />
<br />
<strong class='bbc'>The return value is:</strong><br />
de: |org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@39d2c28a| <br />
<br />
<strong class='bbc'>I then setup the odaDataSource and odaDataSet, </strong><br />
var odaDataSource = new OdaDataSourceDesign( "MyData Source" );<br />
<br />
odaDataSource.setExtensionID( "org.eclipse.birt.report.data.oda.jdbc" );<br />
odaDataSource.addPublicProperty( "odaURL", dsrc.getProperty("odaURL").toString() );<br />
odaDataSource.addPublicProperty( "odaDriverClass", dsrc.getProperty("odaDriverClass").toString());<br />
odaDataSource.addPublicProperty( "odaUser", dsrc.getProperty("odaUser").toString() );<br />
odaDataSource.addPublicProperty( "odaPassword", dsrc.getProperty("odaPassword").toString() ); <br />
<br />
<br />
var odaDataSet = new OdaDataSetDesign( "dsNewDataset" );<br />
odaDataSet.setDataSource( odaDataSource.getName( ) );<br />
odaDataSet.setExtensionID( "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );<br />
strSql = "select * from myGtTable";<br />
odaDataSet.setQueryText( strSql ); <br />
<br />
de.defineDataSet( odaDataSet );<br />
var pq = de.prepare( queryDefinition );<br />
var qr = pq.execute( null );<br />
<br />
<br />
<strong class='bbc'>but when I try to define, prepare and execute them I get the error</strong><br />
<br />
10:50:35 AM EST - Error de.defineDataSet("OdaJDBCDriverPassInConnection") <br />
|Cannot find function defineDataSet in object org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@201044a7.|<br />
10:50:35 AM EST -
<br />
10:50:35 AM EST - Overall Error Catch<br />
10:50:35 AM EST - Error: |Cannot find function printStackTrace in object TypeError: Cannot find function defineDataSet in object org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@201044a7..|<br />
10:50:35 AM EST - <br />
10:50:35 AM EST - beforeFactory -- ENDING --<br />
10:50:35 AM EST - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
<br />
<br />
<strong class='bbc'>please show me the light</strong><br />
I'm not sure where I am going wrong. If I generate a new connetion from the code below the scripting above works but I don't have access to my GT table. Where am I missing the bus on this issue. If someone can show me the error of my ways I will be greatly be indebit to you.<br />
<br />
var myconfig = reportContext.getReportRunnable().getReportEngine().getConfig();<br />
var de = DataEngine.newDataEngine( myconfig, null );<br />
<br />
<br />
thanks in advance!<br />
Mike W
Find more posts tagged with
Comments
kclark
What imports do you have in your code? You might try these<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage( Packages.org.eclipse.birt.report.model.api );
importPackage(Packages.java.lang);
importPackage(Packages.java.util);
importPackage(Packages.org.eclipse.birt.data.engine.api);
importPackage(Packages.org.eclipse.birt.report.model.api);
importPackage(Packages.org.eclipse.birt.data.engine.api.querydefn);
importPackage(Packages.org.eclipse.birt.data.engine.core);</pre>
wirzbicki
Hi,
In my initialize method I import the following packages
importPackage( Packages.java.io );
//importPackage(Packages.java.lang);
//importPackage(Packages.java.util);
importPackage(Packages.org.eclipse.birt.data.engine.api);
importPackage(Packages.org.eclipse.birt.report.model.api);
importPackage(Packages.org.eclipse.birt.data.engine.api.querydefn);
importPackage(Packages.org.eclipse.birt.data.engine.core);
importPackage( Packages.org.eclipse.birt.report.model.api );
the java language and util gives me errors so that is why I have it commented out.
wirzbicki
So don't I simply need the ability to get access to the same datasource instance? Or am I not correct in my understanding? I don't claim to be an expert yet in this but I am working at it!
kclark
What are the errors you get when you import java.lang and java.util? Can you post your rptdesign for me to look at?
wirzbicki
I don't really get errors but watch fails to work is creating a log file for all my tracing and debugging when I run the report. it seems like the Packages.java.io get's lost when followed by the Packages.java.lang and Packages.java.util.<br />
<br />
As far as posting the rptdesign I can't really do that because of the client. I know it doesn't help debug my issue but maybe I can do it another way.<br />
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="114878" data-time="1362695435" data-date="07 March 2013 - 03:30 PM"><p>
What are the errors you get when you import java.lang and java.util? Can you post your rptdesign for me to look at?<br /></p></blockquote>
wirzbicki
Just a update I narrow the package that stop the log file from being written to as the Packages.java.util . I still don't know why it stops the io but I can't believe this is related to the problem for the original question which is trying to get the exising db connection object for the report.<br />
<br />
Again I can successfully create and use new connections but I need to use the existing one because we execute sql packages or objects prior to the report running which creates GT(Global Temp) Tables. I need to get access to them in the beforeFactory event so I can dynamically create columns on the as needed.<br />
<br />
I can't believe I'm the first one to ever want to do this. Is the connection object( for lack of a better name) private? We do a <br />
<strong class='bbc'>reportContext.getAppContext().put("OdaJDBCDriverPassInConnection", conn);</strong><br />
<br />
to pass one into the report I would think the "get" method would return it back.<br />
<br />
Thanks again to all who look at this thread!<br />
<br />
Mike W.
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'wirzbicki'" data-cid="114909" data-time="1362756233" data-date="08 March 2013 - 08:23 AM"><p>
I don't really get errors but watch fails to work is creating a log file for all my tracing and debugging when I run the report. it seems like the Packages.java.io get's lost when followed by the Packages.java.lang and Packages.java.util.<br />
<br />
As far as posting the rptdesign I can't really do that because of the client. I know it doesn't help debug my issue but maybe I can do it another way.<br /></p></blockquote>
wirzbicki
Update to kclark question of why I cannot use packages.java.util.<br />
<br />
"User Error", I have a function within my report design file call <strong class='bbc'>"log"</strong> which is the same name of the <strong class='bbc'>log method</strong> that packages.java.util define.<br />
<br />
I change my "log" function name to "MyLog" so there is no-longer a confict and now can declare without issue the util package.<br />
<br />
What's interesting is that I didn't get any confict error messages a runtime when I was running the report (from within eclipse UI environment).<br />
<br />
I am still now left trying to get the db handle from the report so I can get access to the GT (Global Temp) tables that get generated prior to the report being call.<br />
<br />
Any ideas will be greatly appreciated!<br />
<br />
Mike W.