Erro - parametro para Ireport

0 respostas
N

oque tem que errado no meu codigo!

segue a classe completa:

package relatoriojava;

import java.security.Timestamp;

import java.sql.Connection;

import java.sql.DriverManager;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.HashMap;

import net.sf.jasperreports.engine.JasperFillManager;

import net.sf.jasperreports.engine.JasperPrint;

import net.sf.jasperreports.engine.JasperReport;

import net.sf.jasperreports.engine.util.JRLoader;

import net.sf.jasperreports.view.JasperViewer;

/**
*

  • @author  danilo
    
    <em>/
    
    public class FiltroRelatorio extends javax.swing.JFrame {
    
    private static String driver = sun.jdbc.odbc.JdbcOdbcDriver;
    
    private static String MDB = C:\bancoacess\dados.MDB;
    
    private static String url = "jdbc:odbc:Driver={Microsoft Access Driver (</em>.mdb)};DBQ=" + MDB;
    
    private static String login = admin;
    
    private static String senha = “”;
    
    public static Connection conexao;
    
    public static ConexaoMDB banco;
    
    private static SimpleDateFormat formato = new SimpleDateFormat(dd/MM/yyyy, hh:mm:ss);
    
    /** Creates new form FiltroRelatorio */
    
    public FiltroRelatorio() {
    
    initComponents();
    
    }
    

    /** This method is called from within the constructor to

    • initialize the form.

    • WARNING: Do NOT modify this code. The content of this method is

    • always regenerated by the Form Editor.
      
      */
      
      @SuppressWarnings(unchecked)
      
      // 
      
      private void initComponents() {
      

      Ecampo = new javax.swing.JTextField();
      jButton1 = new javax.swing.JButton();

      setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

      jButton1.setText(Filtrar);
      
      jButton1.addActionListener(new java.awt.event.ActionListener() {
      
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      
      jButton1ActionPerformed(evt);
      
      }
      
      });
      
      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
      
      getContentPane().setLayout(layout);
      
      layout.setHorizontalGroup(
      
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      
      .addGroup(layout.createSequentialGroup()
      
      .addGap(19, 19, 19)
      
      .addComponent(Ecampo, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
      
      .addGap(18, 18, 18)
      
      .addComponent(jButton1)
      
      .addContainerGap(29, Short.MAX_VALUE))
      
      );
      
      layout.setVerticalGroup(
      
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      
      .addGroup(layout.createSequentialGroup()
      
      .addGap(23, 23, 23)
      
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
      
      .addComponent(jButton1)
      
      .addComponent(Ecampo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
      
      .addContainerGap(26, Short.MAX_VALUE))
      
      );
      
      java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
      
      setBounds((screenSize.width-212)/2, (screenSize.height-99)/2, 212, 99);
      
      }//
      
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

try {

Class.forName(driver);

conexao = DriverManager.getConnection(url, login, senha);

JasperReport relatorio = (JasperReport) JRLoader.loadObject(C:/bancoacess/relatoriotag.jasper);

HashMap parametros = new HashMap();

Date data = formato.parse(Ecampo.getText());

Timestamp dataInicial = new Timestamp(data.getTime());  O ERRO ESTA AQUI

parametros.put(data, dataInicial);

JasperPrint impressao = JasperFillManager.fillReport(relatorio, parametros, conexao);

//ve aqui eu coloquei o parametro false depois da impressao pra nao fechar o sistema
JasperViewer visualizador = new JasperViewer(impressao, false);
        visualizador.setVisible(true);
        
    } catch (Exception e) {
        e.printStackTrace();
    }

}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new FiltroRelatorio().setVisible(true);
        }
    });
}

// Variables declaration - do not modify                     
private javax.swing.JTextField Ecampo;
private javax.swing.JButton jButton1;
// End of variables declaration

}

Criado 9 de julho de 2008
Respostas 0
Participantes 1