Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Scripted datasource: JDBC driver, problems with BIRT(Using JDBC in a Java object -> scripted data source, not finding driver)
icon4.gif  Scripted datasource: JDBC driver, problems with BIRT [message #494053] Wed, 28 October 2009 23:11 Go to next message
Doug  is currently offline Doug Friend
Messages: 5
Registered: October 2009
Junior Member
Hello,

I'm having a terrible time trying to figure out this issue with a scripted data source linked to a Java object which connects to a MySQL database.

* What I'm trying to do:
At a high-level I want to run several SQL queries against a DB, combine and process the results, stuff them in a list, and then pass the list to BIRT for charting via a scripted data source.

* What I've done:
First of all, I downloaded the JDBC MySQL driver from the MySQL website. I placed this .jar in my path in addition to my JDK/JRE directory.

Created a Java class that stores data (DataStore) and a Java class that accesses the database (DAO). These work fine - the DAO object runs its queries, places results in a DataStore, and adds the DataStore to a list. Again, these work as expected, successfully connecting to the DB, successfully running queries, and successfully returning the list which contains DataStore objects.

Now in BIRT, I set up a scripted data source and an associated data set - these work fine. If I use my DAO class to add simple dummy values to the list, I can retrieve those values via my scripted data source/data set in BIRT.

Changing my DAO class to do as it's supposed to and access the DB initially posed problems in BIRT - BIRT couldn't access the JDBC driver. I finally figured out that I had to copy the driver .jar to "C:\Program Files\eclipse\plugins\org.eclipse.birt.report.viewer_2.5.1.v 20090821\birt\WEB-INF\lib\ ", even though the driver was in my path as well as in my Java directory. Fine. At this point, when PREVIEWING the data in the data set window, I do see all of my results as expected.

HOWEVER - when trying to set up a line chart in BIRT to access this data, BIRT again can not find the driver. Whether I try to see the data in the PREVIEW portion of the chart properties window, the preview tab for previewing the overall report itself, or when running the report and trying to view it in a web browser, BIRT cannot find the JDBC driver.

So, I tried ALSO copying the JDBC driver to:

C:\Program Files\eclipse\plugins\org.eclipse.birt.resources_2.5.1.v2009 0821\resources\

and to

C:\Program Files\eclipse\plugins\org.eclipse.birt.report.viewer_2.5.1.v 20090821\birt\scriptlib\

for a total of THREE DIFFERENT places within the plugins directory of eclipse. This puts the JDBC driver, overall, in five places on my system. STILL, these problems persist.

Does anyone know WHERE I have to put this JDBC driver for BIRT to be able to correctly invoke my Java object in such a way that it finds the JDBC driver and use it appropriately?


[Updated on: Wed, 28 October 2009 23:16]

Report message to a moderator

Re: Scripted datasource: JDBC driver, problems with BIRT [message #494210 is a reply to message #494053] Thu, 29 October 2009 15:10 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Doug,

you should have it in only one place. Multiple copies will most likely
cause issues.

Generally drivers are put here for BIRT
\plugins\org.eclipse.birt.report.data.oda.jdbc_2.5.1.v200908 21\drivers

If you build a mysql connection with the normal JDBC driver you have the
option to use the gui to copy it.

Next put your jar that contains your class in
\eclipse\plugins\org.eclipse.birt.report.viewer_2.5.1.v20090 821\birt\scriptlib

Restart eclipse with the -clean and it should work.

You can also just create the Java project in the same workspace as the
report project and not have to do any copying of files. By default the
engine will find Java classes in the same workspace that are defined in
a Java project.

BTW using some script you can change the location of a drivers directory
like:
reportContext.getAppContext().put("OdaJDBCDriverClassPath",
"C:/apps/apache-tomcat-5.5.20/webapps/2.5.0/WEB-INF/lib");

Put this script in the beforeFactory or the beforeOpen of your dataset.

Jason



I doubt these

Doug wrote:
> Hello,
>
> I'm having a terrible time trying to figure out this issue with a
> scripted data source linked to a Java object which connects to a MySQL
> database. I tried to make a post about this yesterday but I never saw it
> created, so my apologies if you find this issue from me twice.
>
> * What I'm trying to do:
> At a high-level I want to run several SQL queries against a DB, combine
> and process the results, stuff them in a list, and then pass the list to
> BIRT for charting via a scripted data source.
>
> * What I've done:
> First of all, I downloaded the JDBC MySQL driver from the MySQL website.
> I placed this .jar in my path in addition to my JDK/JRE directory.
>
> Created a Java class that stores data (DataStore) and a Java class that
> accesses the database (DAO). These work fine - the DAO object runs its
> queries, places results in a DataStore, and adds the DataStore to a
> list. Again, these work as expected, successfully connecting to the DB,
> successfully running queries, and successfully returning the list which
> contains DataStore objects.
>
> Now in BIRT, I set up a scripted data source and an associated data set
> - these work fine. If I use my DAO class to add simple dummy values to
> the list, I can retrieve those values via my scripted data source/data
> set in BIRT.
>
> Changing my DAO class to do as it's supposed to and access the DB
> initially posed problems in BIRT - BIRT couldn't access the JDBC driver.
> I finally figured out that I had to copy the driver .jar to "C:\Program
> Files\eclipse\plugins\org.eclipse.birt.report.viewer_2.5.1.v
> 20090821\birt\WEB-INF\lib\ ", even though the driver was in my path as
> well as in my Java directory. Fine. At this point, when PREVIEWING the
> data in the data set window, I do see all of my results as expected.
>
> HOWEVER - when trying to set up a line chart in BIRT to access this
> data, BIRT again can not find the driver. Whether I try to see the data
> in the PREVIEW portion of the chart properties window, the preview tab
> for previewing the overall report itself, or when running the report and
> trying to view it in a web browser, BIRT cannot find the JDBC driver.
>
> So, I tried ALSO copying the JDBC driver to:
>
> C:\Program Files\eclipse\plugins\org.eclipse.birt.resources_2.5.1.v2009
> 0821\resources\
>
> and to
>
> C:\Program Files\eclipse\plugins\org.eclipse.birt.report.viewer_2.5.1.v
> 20090821\birt\scriptlib\
>
> for a total of THREE DIFFERENT places within the plugins directory of
> eclipse. This puts the JDBC driver, overall, in five places on my
> system. STILL, these problems persist.
>
> Does anyone know WHERE I have to put this JDBC driver for BIRT to be
> able to correctly invoke my Java object in such a way that it finds the
> JDBC driver and use it appropriately.
Re: Scripted datasource: JDBC driver, problems with BIRT [message #494877 is a reply to message #494210] Tue, 03 November 2009 03:15 Go to previous messageGo to next message
Doug  is currently offline Doug Friend
Messages: 5
Registered: October 2009
Junior Member
Quote:

Doug,

you should have it in only one place. Multiple copies will most likely
cause issues.

Generally drivers are put here for BIRT
\plugins\org.eclipse.birt.report.data.oda.jdbc_2.5.1.v200908 21\drivers



Yes, this is what I thought originally. In any case, I've removed all copies of the driver except from the location you describe.

Quote:

If you build a mysql connection with the normal JDBC driver you have the
option to use the gui to copy it.

Next put your jar that contains your class in
\eclipse\plugins\org.eclipse.birt.report.viewer_2.5.1.v20090 821\birt\scriptlib

Restart eclipse with the -clean and it should work.

You can also just create the Java project in the same workspace as the
report project and not have to do any copying of files. By default the
engine will find Java classes in the same workspace that are defined in
a Java project.



This report project IS in the same workspace as the Java project. If you re-read my original post I point out that the Java object is being accessed successfully by BIRT, and if I add dummy values programmatically in my Java class BIRT is indeed able to fetch and graph them.

It's only when I re-write my Java class to actually use the JDBC driver and access the MySQL DB that BIRT fails.

The situation is this:
* I have set up a Java object that accesses a MySQL DB. Outside of BIRT this works just fine.
* I copied the JDBC driver to the exact location that you describe. I created a script that successfully retrieves data from my Java object.
* My script functions just fine. If I set up my Java object to access the MySQL DB I CAN see the data from the SQL queries in BIRT - but ONLY IN THE DATA SET PREVIEW.
* Outside of data set preview, BIRT FAILS TO FIND THE JDBC DRIVER - whether I try to render the report, or preview the data in the CHART PREVIEW, or view the data in the overall report preview - BIRT FAILS TO FIND THE JDBC DRIVER.

This issue *IS NOT* that I'm having trouble accessing the DB within a direct MySQL connection via the BIRT "New Data Source" -> "JDBC Data Source" data source - THIS WORKS FINE.

What I AM trying to do is PROGRAMMATICALLY, through a JAVA OBJECT, access a MySQL DB, set up in BIRT as a "Scripted Data Source".

Again - my Java object and my script work fine. BIRT can render the data correctly in the PREVIEW window of the "Edit Data Set" window (ie. double click on the data set -> "Preview Results"). Outside of THIS PARTICULAR PREVIEW window, BIRT fails to find/access/invoke the JDBC driver.

My last ditch effort is to generate flat files from an outside set of Java class and then import the data from these flat files into BIRT. I think it's pretty sloppy that BIRT can find and access the JDBC driver in one tiny sub-application, the data preview window of the data set properties, but not in any other context.


--
Doug


[Updated on: Tue, 03 November 2009 03:16]

Report message to a moderator

Re: Scripted datasource: JDBC driver, problems with BIRT [message #495013 is a reply to message #494877] Tue, 03 November 2009 14:36 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Doug,

Before I wrote a reply to the last post I tried exactly what you are
doing. I created a report project and a Java project in the same
workspace. I added the driver to my build path and put it in the
drivers directory. I wrote a Java class that returned a vector from
MySQL. I called this class from a scripted data source and it worked fine.

As another test I exported my classes into a jar located here:
eclipse\plugins\org.eclipse.birt.report.viewer_2.5.1.v200908 21\birt\scriptlib
and closed the Java project, restarted eclipse with -clean and ran my
test again and everything worked fine.

Jason


Doug wrote:
> Quote:
>> Doug,
>>
>> you should have it in only one place. Multiple copies will most likely
>> cause issues.
>>
>> Generally drivers are put here for BIRT
>> \plugins\org.eclipse.birt.report.data.oda.jdbc_2.5.1.v200908 21\drivers
>
>
> Yes, this is what I thought originally. In any case, I've removed all
> copies of the driver except from the location you describe.
>
> Quote:
>> If you build a mysql connection with the normal JDBC driver you have the
>> option to use the gui to copy it.
>>
>> Next put your jar that contains your class in
>> \eclipse\plugins\org.eclipse.birt.report.viewer_2.5.1.v20090
>> 821\birt\scriptlib
>>
>> Restart eclipse with the -clean and it should work.
>>
>> You can also just create the Java project in the same workspace as the
>> report project and not have to do any copying of files. By default the
>> engine will find Java classes in the same workspace that are defined in
>> a Java project.
>
>
> This report project IS in the same workspace as the Java project. If you
> re-read my original post I point out that the Java object is being
> accessed successfully by BIRT, and if I add dummy values
> programmatically in my Java class BIRT is indeed able to fetch and graph
> them.
> It's only when I re-write my Java class to actually use the JDBC driver
> and access the MySQL DB that BIRT fails.
>
> The situation is this: * I have set up a Java object that accesses a
> MySQL DB. Outside of BIRT this works just fine.
> * I copied the JDBC driver to the exact location that you describe. I
> created a script that successfully retrieves data from my Java object.
> * My script functions just fine. If I set up my Java object to access
> the MySQL DB I CAN see the data from the SQL queries in BIRT - but ONLY
> IN THE DATA SET PREVIEW.
> * Outside of data set preview, BIRT FAILS TO FIND THE JDBC DRIVER -
> whether I try to render the report, or preview the data in the CHART
> PREVIEW, or view the data in the overall report preview - BIRT FAILS TO
> FIND THE JDBC DRIVER.
>
> This issue *IS NOT* that I'm having trouble accessing the DB within a
> directly MySQL connection via the BIRT "New Data Source" -> "JDBC Data
> Source" data source - THIS WORKS FINE.
>
> What I AM trying to do is PROGRAMMATICALLY, through a JAVA OBJECT,
> access a MySQL DB, set up in BIRT as a "Scripted Data Source".
> Again - my Java object and my script work fine. BIRT can render the data
> correctly in the PREVIEW window of the "Edit Data Set" window (ie.
> double click on the data set -> "Preview Results"). Outside of THIS
> PARTICULAR PREVIEW window, BIRT fails to find/access/invoke the JDBC
> driver.
>
> My last ditch effort is to generate flat files from an outside set of
> Java class and then import the data from these flat files into BIRT. I
> think it's pretty sloppy that BIRT can find and access the JDBC driver
> in one tiny sub-application, the data preview window of the data set
> properties, but not in any other context.
>
>
> --
> Doug
>
>
>
>
> Quote:
>> BTW using some script you can change the location of a drivers directory
>> like:
>> reportContext.getAppContext().put("OdaJDBCDriverClassPath",
>> "C:/apps/apache-tomcat-5.5.20/webapps/2.5.0/WEB-INF/lib");
>>
>> Put this script in the beforeFactory or the beforeOpen of your dataset.
>>
>> Jason
>
Re: Scripted datasource: JDBC driver, problems with BIRT [message #495110 is a reply to message #495013] Tue, 03 November 2009 19:44 Go to previous messageGo to next message
Doug  is currently offline Doug Friend
Messages: 5
Registered: October 2009
Junior Member
Is there any way you could archive and send me your project which contains these DB access and report elements?

bryantd (AT) gmail (DOT) com

Thanks a ton for your input.


--
Doug

Re: Scripted datasource: JDBC driver, problems with BIRT [message #495131 is a reply to message #495110] Tue, 03 November 2009 21:07 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Sent

Doug wrote:
> Is there any way you could archive and send me your project which
> contains these DB access and report elements?
>
> bryantd (AT) gmail (DOT) com
>
> Thanks a ton for your input.
>
>
> --
> Doug
>
>
Previous Topic:JavaScript jar missing in Chart Engine 2.5.1 DeploymentRuntime\ChartEngine?
Next Topic:include a pdf into a birt report possible?
Goto Forum:
  


Current Time: Fri Apr 26 14:49:45 GMT 2024

Powered by FUDForum. Page generated in 0.03176 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top