Olá Colegas,
Estou começando a mexer com a parte de relatorios em java, so que esta ocorendo um erro na hora de executar e nao sei como resolver, abaixo estou colocando o código e o erro, testei o relatorio no iReport e lá ele funciona.Só na classe java não funciona.
Alguém pode me ajudar?
[code]/*
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;
public class RelatorioAlmoxarifados {
private static Connection getConnection() throws ClassNotFoundException, SQLException
{
String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url = "jdbc:microsoft:sqlserver://192.168.0.3:1433;DatabaseName=teste";
String user = "sa"; String password = "****"; Class.forName(driver);
Connection con = DriverManager.getConnection( url, user, password );
return con;
}
/* Gera Relatorio e visualiza-o */
public void geraRelatorio( ) throws JRException, Exception
{
Connection con = getConnection( );
Statement stm = con.createStatement( );
String query = "select * from almoxarifados";
ResultSet rs = stm.executeQuery( query );
JRDataSource jrRS = new JRResultSetDataSource( rs );
Map parameters = new HashMap();
JasperReport jasperReport = JasperCompileManager.compileReport("RelatorioAlmoxarifados.jrxml");
JasperPrint impressao = JasperFillManager.fillReport(jasperReport,parameters,jrRS);
JasperViewer viewer= new JasperViewer( impressao,true );
viewer.setVisible(true);
}
public static void main(String[] args) throws JRException, Exception
{
new RelatorioAlmoxarifados().geraRelatorio();
}
}
[/code]
Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:186)
at manutencao.RelatorioAlmoxarifados.geraRelatorio(RelatorioAlmoxarifados.java:62)
at manutencao.RelatorioAlmoxarifados.main(RelatorioAlmoxarifados.java:78)