Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%
- String datef =request.getParameter("datef");
- String datet =request.getParameter("datet");
- try {
- //String connectionURL = "jdbc:mysql://localhost:3306/test";
- // Connection conn = null;
- // Class.forName("com.mysql.jdbc.Driver").newInstance();
- // conn = DriverManager.getConnection(connectionURL, "root", "1234");
- String connectionURL = "jdbc:oracle:thin:@localhost:1522:test";
- Connection conn = null;
- Class.forName("oracle.jdbc.OracleDriver").newInstance();
- conn=DriverManager.getConnection(connectionURL,"system","1234");
- String jrxmlFile ="C:/Users/jfk687/workspace/Employee/WebContent/WEB-INF/report/report1.jrxml";
- InputStream input = new FileInputStream(new File(jrxmlFile));
- JasperDesign jasperDesign = JRXmlLoader.load(input);
- System.out.println("Compiling Report Designs");
- JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
- System.out.println("Creating JasperPrint Object");
- HashMap<String,Object> map = new HashMap<String,Object>();
- map.put("datef",datef);
- map.put("datet",datet);
- JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,map,conn);
- byte bytes[] = new byte[10000];
- JRPdfExporter exporter = new JRPdfExporter();
- ByteArrayOutputStream PDFStream = new ByteArrayOutputStream();
- exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
- exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, PDFStream);
- exporter.exportReport();
- System.out.println("Size of byte array:"+PDFStream.size());
- bytes = PDFStream.toByteArray();
- response.setContentType("application/pdf");
- response.setContentLength(bytes.length);
- PDFStream.close();
- OutputStream outputStream = response.getOutputStream();
- outputStream.write(bytes, 0, bytes.length);
- outputStream.flush();
- outputStream.close();
- }catch(Exception ex){
- out.println("Error"+ex);
- }
- %>
- SELECT
- CI_ID,
- Status,
- CI_name,
- Serial_num,
- Manufacturer,
- model,
- warranty_end,
- refresh_date,
- core_id,
- departm
- FROM
- laptop
- WHERE
- refresh_date >= $P{datef}
- and refresh_date <= $P{datet}
- ORDER BY
- refresh_date ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement