public void myConnection(){ String HOST = "jdbc:mysql://localhost:3306/db"; String USER = "user"; String PASS = "pass"; conn = DriverManager.getConnection(HOST, USER, PASS);
JasperFillManager.fillReportToFile("report.jasper", parameters, myConnection());
JasperFillManager.fillReportToFile("report.jasper", null, new JREmptyDataSource(5));
<?xml version="1.0" encoding="UTF-8"?> <csvDataAdapter class="net.sf.jasperreports.data.csv.CsvDataAdapterImpl"> <name>csv</name> <fileName>/data/CsvDataSource.csv</fileName> <recordDelimiter> </recordDelimiter> <useFirstRowAsHeader>false</useFirstRowAsHeader> <queryExecuterMode>true</queryExecuterMode> <datePattern>yyyy-MM-dd HH:mm:ss</datePattern> <columnNames>address</columnNames> <columnNames>latitude</columnNames> <columnNames>longitude</columnNames> <columnNames>size</columnNames> <columnNames>color</columnNames> <columnNames>url</columnNames> <columnNames>icon</columnNames> <columnNames>iconurl</columnNames> <columnNames>iconwidth</columnNames> <columnNames>iconheight</columnNames> </csvDataAdapter>
Note: fileName can be in file system or repo:
<jasperReport
xmlns="http://jasperreports.sourceforge.net/jasperreports"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
name="CustomersReport" pageWidth="595" pageHeight="842" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50">
<property name="net.sf.jasperreports.data.adapter" value="/data/myAdapter.xml"/>
As "sub-dataset":
<subDataset name="MarkersDataset">
<property name="net.sf.jasperreports.data.adapter" value="/data/myAdapter.xml"/>
Note: files can be referenced in file system (example) or in repo: syntax