posted 19 years ago
Hi there...
i am currently experimentating with ireport and jasper report... i have the following code:
public void display()
{
FileInputStream file = new FileInputStream("D:\\reports_jasper\\JASPER\\report1.jasper");
System.out.println("loading report.. file read "+file.available());
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(file);
System.out.println("Successfully created jasper report");
java.sql.Connection con=null;
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost/eply",
"user", "123");
if(!con.isClosed())
System.out.println("Successfully connected to MySQL server using TCP/IP...");
}
catch(Exception e)
{
System.out.println("Exception: "+ e);
}
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,null,con);
JasperViewer.viewReport(jasperPrint,false);
}
catch(Exception e)
{
System.out.println("There is exception here"+ e);
}
}
When i run my code, it gives me an error like below:
loading report.. file read 14143
There is exception herenet.sf.jasperreports.engine.JRException: Error loading object from InputStream
It will never print successfully created jasper report.. so i guess it has to do with my loading of the jasper report file.
i use ireport to create my report and it compile the report1.jrxml into report1.jasper. i dun understand the error. i included the jasperreports-0.6.2.jar into my library which i run under eclipse. is there any other things that i miss out?
chris