Olá galera! é um prazer para mim poder participar deste forum e aprender mais sobre esta linguagem que tantos desejam dominar.
Estou solicitando a ajuda de vcs para resolver um problema com relação ao sistema que estou criando onde será necessário a geração de relatórios. estou conseguindo gerar os relatorios diretamente no ireport só não consigo fazer que a aplicação chame o relatório através de um botão.
espero que vcs possam me ajudar.
sou iniciante no java se puderem me explicar os procedimentos ficarei muito grato.
Boa tarde
Então wanderley, o processo de chamada de um arquivo .jasper (ireport) por uma aplicação consiste em uma classe e algumas bibliotecas .jar, me passe seu e-mail que te encaminho as classes e os jars necessários.
Falou.
olá Caio agradeço a sua disposição de me ajudar
ai vai meu email
wanderleypatricio_lima@hotmail.com
Boa tarde
Então enviei para seu e-mail umas apostilas de jasper, lá ensina como fazer a classe de comunicação.
Espero ter ajudado.
Falou.
olá pessoal.
gostaria muito de receber também!
marcosvidolin@uol.com.br
Feliz Natal a todos!
Se não for abuso, poderia enviar para mim tb?
jrmiran@gmail.com
[]'s
Pra quem quer saber como se chamar um relatorio jasper tem que acrescentar alguns jars no classpath e segue o codigo para chamar
public static JasperPrint gerarEmpresa() {
JasperPrint rel = null;
try
{
conectar();
Map map = new HashMap();
map.put("data", data()+" and "+pago()+" and "+conta()+" and moviment_conta_pagar.CANCELADO = 'N'");// metodos chamados!
map.put("SQ",dat());
map.put("saldo",saldo());
rel = JasperFillManager.fillReport("Relatorio_movimentacao.jasper", map, conn);
//JOptionPane.showMessageDialog(null, conta()+" - "+pago()+" - "+data());
}
catch (JRException e) {
JOptionPane.showMessageDialog(null, "Erro: "+e);
e.printStackTrace();
}
return rel;
}
e o codigo do evento do botão
public void actionPerformed(java.awt.event.ActionEvent e) {
table.requestFocus();
JasperViewer jv = new JasperViewer(gerarEmpresa(), false);
jv.setVisible(true);
jv.setTitle("Relatório");
jv.setExtendedState(jv.MAXIMIZED_BOTH);
jv.setDefaultCloseOperation(jv.DISPOSE_ON_CLOSE);
}
[quote=dudu_sps]Pra quem quer saber como se chamar um relatorio jasper tem que acrescentar alguns jars no classpath e segue o codigo para chamar
public static JasperPrint gerarEmpresa() {
JasperPrint rel = null;
try
{
conectar();
Map map = new HashMap();
map.put("data", data()+" and "+pago()+" and "+conta()+" and moviment_conta_pagar.CANCELADO = 'N'");// metodos chamados!
map.put("SQ",dat());
map.put("saldo",saldo());
rel = JasperFillManager.fillReport("Relatorio_movimentacao.jasper", map, conn);
//JOptionPane.showMessageDialog(null, conta()+" - "+pago()+" - "+data());
}
catch (JRException e) {
JOptionPane.showMessageDialog(null, "Erro: "+e);
e.printStackTrace();
}
return rel;
}
e o codigo do evento do botão
public void actionPerformed(java.awt.event.ActionEvent e) {
table.requestFocus();
JasperViewer jv = new JasperViewer(gerarEmpresa(), false);
jv.setVisible(true);
jv.setTitle("Relatório");
jv.setExtendedState(jv.MAXIMIZED_BOTH);
jv.setDefaultCloseOperation(jv.DISPOSE_ON_CLOSE);
}[/quote]
dudu_sp
cara quais são os imports necessário?
Ai galera ja criei o codigo de acesso ao relatorio mais o sistema ta gerando um erro:
Exception in thread “AWT-EventQueue-0” javax.persistence.PersistenceException: No Persistence provider for EntityManager named bd_saaePU: Provider named oracle.toplink.essentials.PersistenceProvider threw unexpected exception at create EntityManagerFactory:
oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Local Exception Stack:
Exception [TOPLINK-30005] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@11b86e7
Internal Exception: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
Exception Description: predeploy for PersistenceUnit [bd_saaePU] failed.
Internal Exception: Exception [TOPLINK-30007] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while loading class: SAAE.View.Bacteriologica to check whether it implements @Entity, @Embeddable, or @MappedSuperclass.
Internal Exception: java.lang.ClassNotFoundException: SAAE.View.Bacteriologica
at oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:143)
at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:169)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:110)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
at SAAE.View.BacteriologicaView.initComponents(BacteriologicaView.java:50)
at SAAE.View.BacteriologicaView.(BacteriologicaView.java:34)
at SAAE.View.BacteriologicaView$1.run(BacteriologicaView.java:773)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
Exception Description: predeploy for PersistenceUnit [bd_saaePU] failed.
Internal Exception: Exception [TOPLINK-30007] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while loading class: SAAE.View.Bacteriologica to check whether it implements @Entity, @Embeddable, or @MappedSuperclass.
Internal Exception: java.lang.ClassNotFoundException: SAAE.View.Bacteriologica
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:643)
at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.callPredeploy(JavaSECMPInitializer.java:171)
at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initPersistenceUnits(JavaSECMPInitializer.java:239)
at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initialize(JavaSECMPInitializer.java:255)
at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:155)
… 13 more
Caused by: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
Exception Description: predeploy for PersistenceUnit [bd_saaePU] failed.
Internal Exception: Exception [TOPLINK-30007] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while loading class: SAAE.View.Bacteriologica to check whether it implements @Entity, @Embeddable, or @MappedSuperclass.
Internal Exception: java.lang.ClassNotFoundException: SAAE.View.Bacteriologica
at oracle.toplink.essentials.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:228)
… 18 more
Caused by: Exception [TOPLINK-30007] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while loading class: SAAE.View.Bacteriologica to check whether it implements @Entity, @Embeddable, or @MappedSuperclass.
Internal Exception: java.lang.ClassNotFoundException: SAAE.View.Bacteriologica
at oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException.exceptionLoadingClassWhileLookingForAnnotations(PersistenceUnitLoadingException.java:160)
at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.isEntity(PersistenceUnitProcessor.java:319)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.buildEntityClassSetFromAnnotations(MetadataProcessor.java:491)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.buildEntityList(MetadataProcessor.java:462)
at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:366)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:607)
… 17 more
Caused by: java.lang.ClassNotFoundException: SAAE.View.Bacteriologica
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.isEntity(PersistenceUnitProcessor.java:316)
… 21 more
The following providers:
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
Returned null to createEntityManagerFactory.
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
at SAAE.View.BacteriologicaView.initComponents(BacteriologicaView.java:50)
at SAAE.View.BacteriologicaView.<init>(BacteriologicaView.java:34)
at SAAE.View.BacteriologicaView$1.run(BacteriologicaView.java:773)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
CONSTRUÍDO COM SUCESSO (tempo total: 23 minutos 35 segundos)
Alguém pode me ajudar a resolver isso?
Olá novamente galera ja estou conseguindo fazer a chama do relatorio. O problema agora é que eu quero que o relatório seja chamado com base no campo chamado “num_amostra” do formulario de amostra mestre. Gostaria que vcs me explicassem como faço para adicionar esse parametro no codigo para que o relatorio seja gerado baseado nessa informação. Já tentei fazer alguns testes aki mais os dados do relatorio continuam o mesmo, ate mesmo mudando o numero do registro no formulario.
abaixo vai o codigo:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try{
//busca a conexão com a classe ConexaoMySQL
Connection con = new ConexaoMySQL().getConnection();
HashMap parametro = new HashMap();
parametro.put(“num_amostra”, numAmostraField);
JasperPrint jp = JasperFillManager.fillReport(“c:/aplicativo java/Sistema_SAAE/relatorio/Relatorio_Bacteriologica.jasper”, parametro,con);
JasperViewer jrv = new JasperViewer(jp);
jrv.setVisible(true);
}catch(Exception e){
e.printStackTrace();
}
olá tem como eu receber as apostilas também?
Olá pessoal, sou iniciante em java e estou fazendo meu TCC, consegui gerar o relatório dentro do java utilizando irreport, mas não consegui chamar em um botão na aplicação.
Será que podem me enviar as apostilas também por favor.
Ou me ajudar de alguma forma quem já executou o procedimento.
Agradeço a atenção de todos. [],