Tolong pilih kategori sesuai, jenis posting (pertanyaan atau bukan) dan sertakan tag/topik yang sesuai misal komputer, php, mysql, dll.
Promosi atau posting tidak pada tempatnya akan kami hapus.
Klik link berikut untuk informasi cara menyisipkan kode program supaya tampil rapi dan terformat dengan baik di diskusiweb.com: http://www.diskusiweb.com/discussion/50415/cara-menyisipkan-kode-program-di-diskusiweb-com

Baca cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

Bagaimana Settingan untuk menampilkan laporan dari ireport menggunakan Netbeans

edited February 2011 in Diskusi Pemrograman & IT
Selamat malam Bro & Sis semua...
Saya mau nanya nich,
Gimana Settingan untuk menampilkan laporan dari ireport menggunakan Netbeans.

Saya udah bnyk ikuti tutorial yang ada didunia maya, tapi selalu error, Coding pada tombol cetak seperti ini :

===================================================
Connection con = null;
try {
String jdbcDriver = "com.mysql.jdbc.Driver";
Class.forName(jdbcDriver);

String url = "jdbc:mysql://localhost/java_db";
String user = "root";
String pass = "";

con = DriverManager.getConnection(url, user, pass);
Statement stm = (Statement) con.createStatement();

try {
Map prs = new HashMap();
JasperReport JRpt = JasperCompileManager.compileReport("/src/andes.jrxml");
JasperPrint JPrint = JasperFillManager.fillReport(JRpt, prs, con);
JasperViewer.viewReport(JPrint, false);
} catch (Exception rptexcpt) {
System.out.println("Report Can’t view because : " + rptexcpt);
}
} catch (Exception e) {
System.out.println(e);
}
======================================================

errorny begini :

Report Can’t view because : net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: \src\andes.jrxml (The system cannot find the path specified)

Hemat saya, mungkin ada settingan pathny yg tidak benar. Tpi jujur saya memg tidk tahu ttg setting pathny itu.
Mohon bantuanny Bro & Sis master...
Terimksh....
Tagged:

Comments

  • iya betul sekali, settingan path yang salah.
    try this:
    klik kanan project, pilih properties. setelah itu muncul jendela project properties. pilih categories RUN lalu ganti "working directory" menjadi lokasi dimana kamu file report tersimpan. trus OK

    selamat mencoba
  • Kala bukan setting pathnya berarti librarynya yg kurang...
    coba klik kanan di project pilih propertis lalu klik library
    pilih add jar/project
    cari path dir jespersoft/lib/
    import beberapa file antara lain:
    o commons-beanutils-1.7
    o commons-javaflow-20060411
    o jasperreports-1.3.2
    o poi-2.0-final-20040126
    o commons-collections-2.1
    o commons-logging-1.0.2
    o jdt-compiler-3.1.1
    o commons-digester-1.7


    selamat mencoba... good luck...
  • Gunakan fungsi System.getProperty("user.dir") untuk mengetahui current directory program anda. Seperti yang tertulis di method setReport dibawah ini. Saya menggunakan Eclipse tapi konsep ny pasti sama.
    Selamat mencoba.

    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.util.HashMap;

    import javax.swing.JInternalFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.border.BevelBorder;

    import net.sf.jasperreports.engine.JREmptyDataSource;
    import net.sf.jasperreports.engine.JasperCompileManager;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.engine.JasperReport;
    import net.sf.jasperreports.engine.design.JasperDesign;
    import net.sf.jasperreports.swing.JRViewer;



    public class WindowPrintDP3 extends JInternalFrame
    {

    /**
    *
    */
    private static final long serialVersionUID = 1L;

    private Container content;
    private JasperDesign jasperDesign;
    private JasperReport jasperReport;
    private JasperPrint jasperPrint;
    private JRViewer viewer;
    private MainDesktop mainDesktop;
    private String currentDir;
    private String fileName;
    private HashMap parameter;
    private Koneksi koneksi;


    public WindowPrintDP3 (MainDesktop mainDesktopReff)
    {
    super ("DP3");
    mainDesktop = mainDesktopReff;
    }



    //set report
    public void setReport (String id_DesaRef)
    {
    currentDir = System.getProperty("user.dir");
    fileName = currentDir +"/Report/DP3Report.jrxml";

    try {
    parameter = new HashMap ();
    parameter.put("ID_SEARCH", id_DesaRef);
    jasperDesign = JasperManager.loadXmlDesign(fileName);
    jasperReport = JasperCompileManager.compileReport(jasperDesign);
    jasperPrint = JasperFillManager.fillReport(jasperReport, parameter, koneksi.connection);
    viewer = new JRViewer(jasperPrint);

    } catch (Exception e) {
    // TODO Auto-generated catch block
    JOptionPane.showMessageDialog(this, "Error in load Reporting at WindowPrintDP3\n details " +e);
    }

    }//end set report

    //set GUI
    public void setGUI ()
    {
    content = getContentPane();
    content.setLayout(new BorderLayout());

    content.add(new JScrollPane(viewer, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS), BorderLayout.CENTER);
    mainDesktop.addWindowToDesktop(this);

    }//end set GUI

    public void getSelfKoneksi (Koneksi koneksi)
    {
    this.koneksi = koneksi;
    }



    }
  • kalo erornya gini apa yah??

    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/springframework/core/io/Resource
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:161)
        at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:119)
        at net.sf.jasperreports.engine.util.ClassUtils.instantiateClass(ClassUtils.java:57)
        at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.instantiateRegistry(DefaultExtensionsRegistry.java
  • Silahkan cek pada Libraries, jangan ada library atau jangan tambahkan add library dengan icon seperti buku. sebaiknya gunakan jar dengan icon seperti botol. Silahkan dicoba dan saya berhasil ketika terjadi masalah seperti itu. Terimakasih
Sign In or Register to comment.