2005 IR Help Posted August 20, 2006 Share Posted August 20, 2006 By: balaji sampath - balajisampath How to retrieve data from mysql 2004-01-11 09:11 Hello, I am able to compile the report design (.xml file) and generate the jasper file, when I tried to execute the following code for filling the data from mysql database, an exception stating the following error message is displayed. Servlet Execution throw an exception. ………. Root Cause Abstract Method Error in JRFiller() and JRBaseFiller………. But the connection is properly established and I am not sure whether the data is retrieved from the database. Source Code: public void service( HttpServletRequest request, HttpServletResponse response ) throws IOException, ServletException { ServletContext context = this.getServletConfig().getServletContext(); response.setContentType("text/html"); PrintWriter out = response.getWriter(); try { String driver = "org.gjt.mm.mysql.Driver"; String connectString = "jdbc:mysql://localhost/employees"; String user = "root"; String password = ""; Class.forName(driver); Connection conn = DriverManager.getConnection(connectString, user, password); return conn; File reportFile = new File(context.getRealPath("/reports/WebappReport.jasper")); JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath()); Map parameters = new HashMap(); parameters.put("ReportTitle", "Address Report"); parameters.put("BaseDir", reportFile.getParentFile()); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,conn); JRHtmlExporter exporter = new JRHtmlExporter(); Map imagesMap = new HashMap(); request.getSession().setAttribute("IMAGES_MAP", imagesMap); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out); exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image="); exporter.exportReport(); } catch (JRException e) { } } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now