This is finally successfully coded procedure for showing Jasper Report in NetBeans Swing Desktop Application :
public void ShowReport() {
try {
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/neosoft", "postgres", "postgres");
HashMap hm = new HashMap();
JasperReport jre;
jre = JasperCompileManager.compileReport("src//japi//report1.jrxml");
JasperPrint jr = JasperFillManager.fillReport(jre, hm, con);
JasperExportManager.exportReportToHtmlFile(jr, "report1.html");
JasperViewer.viewReport(jr, false);
} catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
} catch (SQLException se) {
System.out.println(se.getMessage());
} catch (JRException ex) {
System.out.println(ex.getMessage());
}
}
Also dont forget to include these jars into library :
public void ShowReport() {
try {
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/neosoft", "postgres", "postgres");
HashMap hm = new HashMap();
JasperReport jre;
jre = JasperCompileManager.compileReport("src//japi//report1.jrxml");
JasperPrint jr = JasperFillManager.fillReport(jre, hm, con);
JasperExportManager.exportReportToHtmlFile(jr, "report1.html");
JasperViewer.viewReport(jr, false);
} catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
} catch (SQLException se) {
System.out.println(se.getMessage());
} catch (JRException ex) {
System.out.println(ex.getMessage());
}
}
Also dont forget to include these jars into library :
No comments:
Post a Comment