JASPERREPORTS
Hi everyone
It磗 making me crazy
I have the following code which should work properly... but the damned doesn磘 do so
Why?
JasperDesign relatorioDefinicao =
JRXmlLoader.load("e:/relatorioMae.jrxml");
JasperReport relatorioCompilado = JasperCompileManager.compileReport(relatorioDefinicao);
JasperPrint relatorioPreenchido =
JasperFillManager.fillReport(rel1, parametros, fonte);
The code above simply loads a XML template from harddisk, compile it and finally populate it with data.
The problem is... I can磘 load the XML template. The path is correct and the file exists
what磗 wrong?
Any help is welcome!!!
Ok thanks..
I磛e changed the original code so that it磗 easier to understand. Here is
import java.sql.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import net.sf.jasperreports.engine.design.*;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.*;
import net.sf.jasperreports.view.*;
import net.*;
import net.sf.*;
public class teste {
public teste(){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection conexao = DriverManager.getConnection("jdbc:mysql://localhost/testes", "root", "mcpmbaibta");
Statement instrucao = conexao.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet resultado = instrucao.executeQuery("select * from mae");
/****************************************************************************************************************************/
/*The following code is responsible for generating the report*/
JRResultSetDataSource fonte = new JRResultSetDataSource(resultado);
/*The following line is the problem... it returns the following in Eclipse
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester*/
JasperDesign relatorioDefinicao = JRXmlLoader.load("e:/relatorioMae.jrxml");
JasperReport relatorioCompilado = JasperCompileManager.compileReport(relatorioDefinicao);
JasperPrint relatorioPreenchido = JasperFillManager.fillReport(relatorioCompilado, new HashMap(), fonte);
JasperViewer.viewReport(relatorioPreenchido,false);
}
catch(Exception excecao){
javax.swing.JOptionPane.showMessageDialog(null, excecao.getMessage(), "Detalhes do erro", 0);
}
}
public static void main(String[] args) {
new teste();
}
}
Thanks everybody
As suggested I磀 have to download digester. I磛e searched for it on Sun
and found a tutorial describing how to integrate JasperReports into
NetBeans which is very similar to Eclipse integrating.
This tutorial says that as you use more advanced Jasper磗 features you must add other Jars that come along with the API... one the these Jars is digester ;D
I磎 going to try it and see what happens... but I磎 sure everything will be Ok
Thanks