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);
}
}
}