Java and Jasper
- by bhargava
Hey Guys,
I have integrated Jasper Reports on my netbeans platform and i am able to generate reports using the following code.
Map<String, Object> params = new HashMap<String, Object>();
Connection conn = DriverManager.getConnection("databaseUrl", "userid","password");
JasperReport jasperReport = JasperCompileManager.compileReport(reportSource);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, conn);
JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest);
JasperViewer.viewReport(jasperPrint);
This stuff works perfect.
But not i am trying to integrate Jasper with GWT.I have my server as glass fish server.
I am getting the Connection object using the followind code.
public static Connection getConnection() {
try {
String JNDI = "JNDI name";
InitialContext initCtx = new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource) initCtx.lookup(JNDI);
Connection conn = (Connection) ds.getConnection();
return conn;
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
and then
Map params = new HashMap();
JasperReport jasperReport = JasperCompileManager.compileReport(reportSource);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, getConnection());
JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest);
JasperViewer.viewReport(jasperPrint);
but i always get Error.I am implementing this on Server.I am having RPC calls to get this method to work when a button is clicked.
Can you please help me how to work on this.(That is to integrate Jasper reports with GWT).
I would highly appreciate any explanation with some code as i am just a beginner.
Thanks