Contoh class untuk menampilkan ireport sederhana dengan Ireport 2.02
public class Latihan {
JasperReport jReport;
JasperPrint jPrint;
JasperDesign jDesign;
Connection conn ;
ResultSet rs = null;
Statement stt = null;
koneksi kon = new koneksi();
String reportku="ReportKu/angota.jrxml";
public void printBerdasarkanNama(String reportku) {
try {
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/Koperasi2?user=postgres&password=arik");
jReport = JasperCompileManager.compileReport(reportku);
jPrint = JasperFillManager.fillReport(jReport, new HashMap(), kon.con);
JasperViewer.viewReport(jPrint);
//JRViewer view =new JRViewer(jPrint);
}
catch(Exception e)
{
System.out.println("Error pada fungsi printBerdasarkanNama"+e);
}
}
public static void main(String [] args)
{
new Latihan();
}
}
Tidak ada komentar:
Posting Komentar