This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Problem with Jasper report Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic

Problem with Jasper report

Bojan Ivkovic

Joined: May 17, 2009
Posts: 7

Can anybody help me?

when i try to run my jasper report from java code, I get this message: java.lang.NullPointerException

My code is:

public class ReportO1 {
public static Connection connectDB() {
Connection jdbcConnection = null;
try {
jdbcConnection = DriverManager
} catch (Exception ex) {
String connectMsg = "Could not connect to the database: "
+ ex.getMessage() + " " + ex.getLocalizedMessage();
return jdbcConnection;

public static void runReport(String datum) {
Map model = new HashMap();
model.put("datum", datum);
try {JasperReport jasperReport = (JasperReport) JRLoader.loadObject("report01.jasper");
Connection jdbcConnection = connectDB();
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, model, jdbcConnection);
JasperViewer.viewReport(jasperPrint, false);
} catch (Exception ex) {
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42958
Please do not post the same question to multiple forums: CarefullyChooseOneForum

Let's continue the discussion in this duplicate thread.
I agree. Here's the link:
subject: Problem with Jasper report
It's not a secret anymore!