It's not a secret anymore!
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 Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic
Author

Problem with Jasper report

Bojan Ivkovic
Greenhorn

Joined: May 17, 2009
Posts: 7
Hi,

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 {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
jdbcConnection = DriverManager
.getConnection("jdbcdbc:baza","Administrator","SuperAdmin");
} catch (Exception ex) {
String connectMsg = "Could not connect to the database: "
+ ex.getMessage() + " " + ex.getLocalizedMessage();
System.out.println(connectMsg);
}
return jdbcConnection;
}

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

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

Let's continue the discussion in this duplicate thread.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Problem with Jasper report
 
It's not a secret anymore!