Using a JDBC Connection inside a java class for POJO data source #1056
-
I'm trying to write a complex report where I need to use some java code to fetch the data and then return it back into BIRT using the POJO data source. I've found a lot of great examples like the stock ticker example for how to actually use the POJO data source with no problems, but I can't seem to find any examples of how to make a database connection inside my class. I've tried a few options 1 ) Created a class with basic JDBC connections. Works fine as a stand alone app. I can even create the POJO data source and data the data set sees my getters, but no matter what I do, it keeps throwing this exception (I'll save the stack trace for now) Using this in my java, so not sure why I get an ODA Exception
Any suggestions? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 5 replies
-
Hello There, I didn't unserstand correctly why you use an POJO data source to get an data set based on it and combine it with an JDBC-data set. In my cases I use "Scripted Data Sources" and create the corresponding data set. Perhapse the idea will help you a little bit. You can also give us a little bit mor ifnormation to assist you. Regards |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am using birt for almost 9 years, we are sending list of pojos/DTOs to
the birt and the birt is displaying all in table format with formatting, is
that what you are looking for?..
…On Sat, 24 Sep, 2022, 21:27 loopist612, ***@***.***> wrote:
Thanks for the quick reply. Yes, I could have done a better job detailing
it, let me try it again.
The data I'm working with is time series data. In particular, it is for
roughly 300 IOT devices that capture data every 5 minutes. This data is
stored in an Oracle database, which doing the math would be 8640 data sets
per device per month (My report would do a month at a time). I need to
create a report that shows any threshold violations. While I don't agree
with the algorithm to do it (defined by a customer), the process would be
iterating through the 8640 measurements one by one, and comparing the
current one to the previous one to see if it is above a certain threshold
(This value is x% > then it's neighbor). Maybe this context helps?
I was thinking the easiest way to do this, since I know java 10x better
than Birt is to somehow get the data from the database, walk through some
Java data structure to do the analysis and return the POJO data set to Birt
to report on the violations. That's where I'm trying to find the best way
for the java side to get this data. *I somehow need to query the DB, have
the Java code do the analysis, and return the Pojo data set.* Now maybe
thats something you can do with a scripted data source. I didn't see how
that was possible when I spent all of last day doing google searches :)
I'm open to ideas, but sticking with the Pojo datasource as a starting
point, can I pass my java code an ODA data source to do it's queries
against? I tried just embeding my own JDBC connection natively, but kept
getting Birt Exceptions. In the meantime, I'm going to focus more time on
the scripted data source since it sounds like a good and different angle.
—
Reply to this email directly, view it on GitHub
<#1056 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAUSMDZPPQMDWVMCG32D2ILV74QGZANCNFSM6AAAAAAQUP7MLI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
You have many options to do this. Option A) "Java&POJO": According to [krishnakittu] would it be make sense to fetch the data directly with Java, execute your analysis, cerate POJO for BIRT-layouting. Option B) "BIRT&Rhino" You can add your java analysis package to BIRT and execute this with the Java-Rhino implementation to get your analysis results. The results could be added to an "scripted data set". Option C) "BIRT&PL/SQL" I work very strongly with PL/SQL because based on the kind of analysis the database in my environment is faster like the java servers. WIth "strongly" I mean, I work with stored procedures, functioncs, loops, recursive CTE-loops for trees and so on. All options are dependent on your kind of analysis and your report target. |
Beta Was this translation helpful? Give feedback.
-
So I was trying to do option A, but I was questioning myself if BIRT was able to cleanly handle that. I created a standalone java app and it pulls the data fine, but when I run it in BIRT, it fails with an exception. `package com.advanta.custom.jdbc; import java.util.ArrayList; public class PojoExample {
}` But when I run it, it just won't create an exception. I have the referenced ojdbc jar in the jar file with this code and in the classpath too. This is the exception I get.
|
Beta Was this translation helpful? Give feedback.
-
Remove your fake exception handling and let it crash to see what's really going on. But - as others said - use the right tools. What you want to do (detect if this value is x% > then it's neighbor) is almost trivial in standard SQL (you don't need PL/SQL at all). |
Beta Was this translation helpful? Give feedback.
-
To summarize, the answer for the intention behind the initial question is: |
Beta Was this translation helpful? Give feedback.
-
Hi loopist612, I tried the same thing but I used mysql, I ask if that connection between Pojo and oracle and birt its succeeded for you . |
Beta Was this translation helpful? Give feedback.
To summarize, the answer for the intention behind the initial question is:
Use a JDBC data source and Oracle SQL instead of a POJO if your data is stored in an oracle database.