É a primeira vez que tento fazer um relatorio utilizando o iReport com o Net Beans veja o codigo
package sistemainvp;
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.JRException;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.view.JasperViewer;
import net.sf.jasperreports.*;
/**
*
-
@author Administrador */ public class RelatorioDosInvestidores { private Statement MeuState; private ResultSet rs; private Object paramters;
/** Creates a new instance of RelatorioDosInvestidores */
public RelatorioDosInvestidores() {}
public void geraRelatorio(String jasperFile) throws SQLException, ClassNotFoundException{
Class.forName("org.gjt.mm.mysql.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/investimentos","root","mysql"); MeuState = conn.createStatement(); rs=MeuState.executeQuery("SELECT * FROM investidor"); JRResultSetDataSource jrRS = new JRResultSetDataSource(rs); Map parameters = new HashMap(); try { JasperFillManager.fillReportToFile(jasperFile, parameters, jrRS); } catch (JRException ex) { ex.printStackTrace(); } /* try { JasperExportManager.exportReportToPdfFile("RelatorioDosInventidores.jrprint"); } catch (JRException ex) { ex.printStackTrace(); } //JasperViewer.viewReport("RelatorioDosInventidores.pdf",false); */
} public static void main (String args[]) throws ClassNotFoundException, SQLException, JRException{ try { new RelatorioDosInvestidores().geraRelatorio(“RelatorioDosInventidores.jasper”); } catch (Exception ex1) { ex1.printStackTrace(); } } }
Quando executo gera o seguinte erro:
init:
deps-jar:
compile-single:
run-single:
net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: RelatorioDosInventidores.jasper
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:75)
at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:443)
at sistemainvp.RelatorioDosInvestidores.geraRelatorio(RelatorioDosInvestidores.java:52)
at sistemainvp.RelatorioDosInvestidores.main(RelatorioDosInvestidores.java:72)
Caused by: java.io.FileNotFoundException: RelatorioDosInventidores.jasper
… 4 more
EXECUTADO COM SUCESSO (tempo total: 6 segundos)
Alguem tem ideia do que possa estar acontecendo?