Agora meu problema é com o iReport. Preciso criar um botão que cria o relatório. Já tenho o corpo do relatório pronto dentro do iReport, só preciso imprimir ele com o meu programinha de cadastro. Ah, e como faço pra passar um parametro pro iReport pra imprimir só o relatório q eu tô querendo e não todos que estão na minha database? Tô usando o Eclipse SDK 3.2.
Só pra constar, o erro que aparece qdo clico no botão é esse:
Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
at cadastro.index$1.actionPerformed(index.java:353)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
net.sf.jasperreports.engine.JRException: Unknown column name : cadastro_CLIENTE
at net.sf.jasperreports.engine.JRResultSetDataSource.getColumnIndex(JRResultSetDataSource.java:356)
at net.sf.jasperreports.engine.JRResultSetDataSource.getFieldValue(JRResultSetDataSource.java:116)
at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:814)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:778)
at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1417)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:111)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:891)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:814)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:517)
at cadastro.index$1.actionPerformed(index.java:385)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Ele não tá achando a coluna cadastro_CLIENTE que já existe dentro do meu relatório do iReport. Já lí e relí o nome das colunas do meu relatório e está tudo certinho, então não sei porque cargas d’água (essa eu puxei não sei de onde) esse código não está funcionando.
Olha se não me engano vc tem que linkar o campo. Pelo menos fiz uma aplicação conversando o Reporting Services, a forma mais sensata de fazer foi:
@Uma Variavel qualquer, ele entende que vc esta linkando.
Dessa forma vc vai passar o valor de acordo com o solicitado, se é o id do relatório, então passa o id e na cosulta do ireport vc recebe o que valor que esta linkado. Se o caminho é esse “C:/workspace/cadastro_manutencao/RelatorioOs.jasper”, vc não concorda que nele tbm tem que ir o parametro. Aqui vai testando, mas acho que o caminho seria este que te avisei.
O meu como estava num servidor ficou dessa forma.
String Acao = “00000C985623”
E no meu relatório estava linkado dessa forma no campo que tinha que receber este valor, para poder pegar o relatório corretamente: @stSDOid. Repare que mandei ele ler.
Veja e estude mais a respeito de passagem de parametro.
gzofera, realmente acho q o meu select dentro do iReport está com problema, pq eu peço pra rodar e ele só fica nessa mensagem e não me mostra o relatório:
Compilando para o arquivo ... .\RelatorioOs.jasper -> C:\Arquivos de programas\JasperSoft\iReport-2.0.4\classic.java
Tempo de execução de compilação: 203
Mas vou fazer como disse meu amigo thokk e estudar mais passagem de parâmetro. Mas se vc tiver alguma outra ideia agradeço.