Thanks,
Maybe you could help me: ( I asked ther to tis question)
I was download iReport & JasperForge.
My goal now is to print all names in a report from java.
What I need for this?
I tried to write this code, but I don't understand why all the examples used whit jasper file, or jrxml file.
I have to create this file?
I just coppy past a few examples and tried to understood them...
Thank you :)
public class laporan {
public laporan() {
}
public void geraRelatorio() throws JRException, Exception, SQLException {
// design
JasperDesign design = JRXmlLoader.load("hello.jrxml");
// report
JasperReport report = JasperCompileManager.compileReport(design); // THIS
// LINE
// CRASH
// request
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager
.getConnection(
"jdbc:sqlserver://matarotsrv:1433;databaseName=qm6",
"sa", "sa");
Statement stm = conn.createStatement();
String query = "SELECT contacts.first_name FROM contacts";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
// JRdataSource
JRDataSource dataSource = new JRResultSetDataSource(rs);
Map params = new HashMap();
JasperPrint print = JasperFillManager.fillReport(report, params,
dataSource);
// exports
JasperExportManager.exportReportToHtmlFile(print, "hello.html");
}
public static void main(String[] args) throws JRException, SQLException,
Exception {
laporan report = new laporan();
report.geraRelatorio();
}
}