I want use sql command how I to do ?
this's is my code and I can read pdf from
<%@ page contentType="application/pdf" %><%@ page trimDirectiveWhitespaces="true"%><%@ page import="net.sf.jasperreports.engine.*" %><%@ page import="java.io.File" %><%@ page import="java.io.FileInputStream" %><%@ page import="java.io.FileNotFoundException" %><%@ page import="java.io.InputStream" %><%@ page import="java.sql.Connection" %><%@ page import="java.sql.DriverManager" %><%@ page import="java.sql.SQLException" %><%Connection conn=null;try {//Connecting to the MySQLClass.forName("com.mysql.jdbc.Driver");conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?user=root&password=passwd1234");String jrxmlFile = session.getServletContext().getRealPath(request.getContextPath())+"/T0113.jrxml";System.out.println("Check file path : "+jrxmlFile);InputStream input = new FileInputStream(new File(jrxmlFile));JasperReport jasperReport = JasperCompileManager.compileReport(input);JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, conn);JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());} catch (FileNotFoundException e) {e.printStackTrace();} catch (JRException e) {e.printStackTrace();} catch (ClassNotFoundException e) {e.printStackTrace();} catch (SQLException e) {e.printStackTrace();}finally {if(conn!=null){conn.close();}}%>
2 Answers:
Posted on January 14, 2016 at 3:15pm
Hi, To add/update a query in studio: use the data set and query editor dialog to the left of the + and - hourglass buttons
top center of the design view main report window. For iReports, use the "Report Query" Button, in the Designer view. The button is to the right of preview.
if you review the jrxml source, your query will look like the following:
<queryString>
<![CDATA[SELECT ...
FROM ...
JOIN ...
ON ...
LEFT OUTER JOIN ...
ON ...
WHERE RVL.VISIT_DATE >= $P{Begin} AND RVL.VISIT_DATE <= $P{End}
AND RVL.REGION = $P{Region}
ORDER BY RVL.REGION, ...]]>
I hope this helps,
Chris Kennedy