Pessoa bom dia,
Estou com um erro na minha chamado para um relatorio desenvolvido em JasperSoft de dentro de uma tela em Java, a tela entrea meu botões de teste são acionados, mas no momento em que executo a chamada do reporte “JasperPrint impressao = JasperFillManager.fillReport( src , parametros, conecta);” recebo a seguinte mensagem … que esta abaixo do meu código…inclui também a classe de conexão…desde já obrigado,
package RelWeb;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import static net.sf.jasperreports.engine.JasperFillManager.fillReport;
import java.awt.event.*;
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;
import javax.swing.*;
public class Botao extends JPanel {
/**
*
*/
Conecta2 conecta = new Conecta2();
private static final long serialVersionUID = 1L;
private JButton btMensagem;
private ImageIcon imageIcon1;
public Botao() throws ClassNotFoundException, SQLException {
inicializarComponentes();
conecta.conexao();
definirEventos();
}
private void inicializarComponentes() {
setLayout(null);
imageIcon1 = new ImageIcon("java.jpg");
btMensagem = new JButton("Mensagem", imageIcon1);
btMensagem.setBounds(320, 420, 140, 38);
add(btMensagem);
}
private void definirEventos () throws ClassNotFoundException, SQLException {
btMensagem.addActionListener(new ActionListener() {
private Map parametros;
public void actionPerformed(ActionEvent e) {
conecta.conexao();
int confirma = JOptionPane.showConfirmDialog(null, "Confirma a impressão", "Atenção", JOptionPane.YES_NO_OPTION);
if(confirma == JOptionPane.YES_OPTION) {
String src = "C:/Users/Computador/JaspersoftWorkspace/MyReports/RelatorioEstoque.jasper";
try {
JasperPrint impressao = JasperFillManager.fillReport( src , parametros, conecta);
} catch (Exception ex) {
JOptionPane.showMessageDialog(getRootPane(), "Erro ao Gerar Relatorio \n" + ex);
}
}
}
});
}
}
Aqui minha classe de conexão…
package RelWeb;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
public class Conecta2 {
public Statement stm;
public ResultSet rs;
private String driver = "oracle.jdbc.driver.OracleDriver";
private String caminho = "jdbc:oracle:thin:@localhost:1521:xe";
private String usuario = "projeto";
private String senha = "projeto";
public Connection con;
public void conexao() {
try {
System.setProperty("jdbc.Drivers", driver);
con=DriverManager.getConnection(caminho, usuario, senha);
JOptionPane.showMessageDialog(null, "Conexão com sucesso 2");
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Conexão não realizada com sucesso/n" + ex);
}
}
//public void desconecta() {
// con.close());
//}
}
Erro…
Exception in thread “AWT-EventQueue-0” java.lang.Error: Unresolved compilation problem:
The method fillReport(String, Map<String,Object>, Connection) in the type JasperFillManager is not applicable for the arguments (String, Map, Conecta2)
at RelWeb.Botao$1.actionPerformed(Botao.java:52)
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.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(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)