Oi pessoal, bem criei um relatorio no ireport, mas não consigo fazer com que eles sejam exibidos,
por exemplo
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package autoescola.modelo;
import autoescola.bancosdedados.conexao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.HashMap;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
/**
*
* @author Administrador
*/
public class GerarRelatorio {
public JasperPrint gerarRelatoriosDeAlunos() throws Exception{
JasperPrint rel=null;
try{
Connection con=conexao.pegarConexao();
HashMap map= new HashMap();
String arquivoJasper= "RelatorioAlunos.jasper";
rel=JasperFillManager.fillReport(arquivoJasper,map,con);
}catch (JRException e){
e.printStackTrace();
}
return rel;
}
public JasperPrint gerarRelatoriosAlunosPorCodigo(int codigo) throws Exception{
try{
Connection con=conexao.pegarConexao();
String arquivoJasper= "RelatorioAlunos.jasper";
String query = "select * from aluno where codigo="+codigo;
Statement s=conexao.pegarConexao().createStatement();
ResultSet rs=s.executeQuery(query);
JRResultSetDataSource tst= new JRResultSetDataSource(rs);
HashMap map= new HashMap();
map.put("QUERY",con);
rel=JasperFillManager.fillReport(arquivoJasper,map,tst);
}catch (JRException e){
e.printStackTrace();
}
return rel;
}
JasperPrint rel=null;
}
esta classe gera os relatorios
e este botão jmenuitem q chama o relatorio
private void VisualisarRelatorioDeAlunosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
GerarRelatorio rep=new GerarRelatorio();
JasperPrint relat;
try {
relat = rep.gerarRelatoriosDeAlunos();
JasperViewer.viewReport(relat,false);
} catch (Exception ex) {
ex.printStackTrace();
}
}
mas queando o programa é executado ocorre este erro
run:
net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: RelatorioAlunos.jasper
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:75)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:232)
at autoescola.modelo.GerarRelatorio.gerarRelatoriosDeAlunos(GerarRelatorio.java:32)
at autoescola.interfaceusuario.Principal.VisualisarRelatorioDeAlunosActionPerformed(Principal.java:668)
at autoescola.interfaceusuario.Principal.access$2700(Principal.java:38)
at autoescola.interfaceusuario.Principal$28.actionPerformed(Principal.java:459)