Results 1 to 3 of 3
  1. #1
    Ed
    Ed is offline Senior Member
    Join Date
    Jun 2007
    Posts
    110
    Rep Power
    0

    Default Jasper Report + iReport + NetBeans 4

    I'm trying to do some reports in jasper, but I have some difficulties to do it, can you help me?
    I downloaded from http://jasperreports.sourceforge.net/

    jasperreports-0.6.5.jar
    jasperreports-0.6.5-applet.jar

    and I copied them in this path:

    C:\j2sdk1.4.2_07\jre\lib\ext

    After that I generated an simple report and compile with iReport 0.4.1

    C:\reports\rep_cli.jasper

    Then I created a project in NetBeans 4 to execute my report, this is the code:

    Code
    Java Code:
    package reportload;
    
    import net.sf.jasperreports.engine.*;
    import net.sf.jasperreports.engine.export.*;
    import net.sf.jasperreports.engine.util.*;
    import net.sf.jasperreports.view.*;
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    
    public class Main {
        
        public Main() {
        }
        
        public static void main(String[] args) {
        
        try
        {
         
            String fileName="C:\\reports\\rep_cli.jasper";
      
            String destFileNamePdf="C:\\reports\\rep_cli.pdf";
     
            String destFileNameXls="C:\\reports\\rep_cli.xls";
    
            Map parameters = new HashMap();
            parameters.put("sql_query", new String("select * from clients"));
    
            JasperPrint jasperPrint=JasperFillManager.fillReport(fileName, parameters, getConnection());
    
            JasperExportManager.exportReportToPdfFile(jasperPrint, destFileNamePdf);
    
     
            JRXlsExporter exporter = new JRXlsExporter();
            exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
            exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFileNameXls);
            exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);
            exporter.exportReport();
    
            System.exit(0);
         }
         catch (Exception e)
         {
                System.out.println(e.getMessage());
         }
        }
        
    
        private static Connection getConnection() throws ClassNotFoundException, SQLException {
            //Configuración de la conexión.
            String driver = "org.postgresql.Driver";
            String connectString = "jdbc:postgresql://192.168.1.7:5432/bdtest";
            String user = "user";
            String password = "123";
    
            Class.forName(driver);
            Connection conn = DriverManager.getConnection(connectString, user, password);
            
          
        return conn;
    }
        
    }
    When I compile the code it returns to me this error in this line:
    Java Code:
            JasperPrint jasperPrint=JasperFillManager.fillReport(fileName, parameters, getConnection());
    the error message is:
    Error loading object from file : C:\reports\rep_cli.jasper
    I don't know what is the problem
    can you help me?
    I am desperate

  2. #2
    Jack is offline Senior Member
    Join Date
    Jun 2007
    Posts
    130
    Rep Power
    0

    Default

    check the versions of your iReport because in the directory of the iReport there is *.jar of the jasperreport you should check with what version you open the reports.

  3. #3
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    7

    Default

    check if these jar are correct
    commons-beanutils.jar
    commons-collections.jar
    commons-digester.jar
    commons-logging.jar
    itext-1.2.jar
    poi-2.5.1-final-20040804.jar

Similar Threads

  1. iReport
    By Freddie in forum Advanced Java
    Replies: 6
    Last Post: 04-20-2010, 06:25 PM
  2. Error With Sql And Jasper Report
    By Heather in forum JDBC
    Replies: 4
    Last Post: 12-03-2008, 11:31 AM
  3. Jasper report + JPQL
    By tarat in forum Advanced Java
    Replies: 2
    Last Post: 08-01-2008, 06:47 PM
  4. org.apache.jasper.JasperException: null
    By ranjan_ashish26 in forum Java Servlet
    Replies: 1
    Last Post: 03-21-2008, 05:06 AM
  5. Jasper iReports and Java
    By shinky in forum New To Java
    Replies: 2
    Last Post: 08-09-2007, 09:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •