File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes JasperReports and databases Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "JasperReports and databases" Watch "JasperReports and databases" New topic

JasperReports and databases

Tom Sakra

Joined: Oct 09, 2010
Posts: 8

So I'm pretty new to JasperReports and iReport, but I've made a report (in iReport) that fetches data from my MySQL
database. However, the problem I'm facing is this:

My MySQL database contains customer numbers, which I don't want to display in my report, but instead I want to display
customer names. Problem is, the names are in an MDB-file (which I have access to by using DSN and JDBC-ODBC), so
how do I access them and fetch the names instead of the number? Both databases contain the customer number for
reference.Is there any way I could use the template report from iReport in Java and do some logic to replace the numbers
with the names?

Edit: I figured out how to resolve my problem. In case anyone is interested, here's how I did it:
Instead of letting JasperReports handle the database connection and all that, I made a new class which implements the
JRDataSource methods for filling a report. Then I just filled the Object[][] with data from my database class. Basically, I
only used iReport to design the report and generate a .jasper-file. Here's how to implement it!
Martijn Verburg

Joined: Jun 24, 2003
Posts: 3275

Hi Tom and welcome to Javaranch and thanks for sharing your solution!!

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
I agree. Here's the link:
subject: JasperReports and databases
It's not a secret anymore!