Problemas ao Ler dados do Oracle

0 respostas
P

Olá Amigos, estou começando no mundo Java, e preciso de uma ajuda !!

Depois de fazer a conexão com o bando Oracle e criar a query,
a aplicação compila sem erros, porem ao fazer uma pesquisa na base, o compilador me apresenta o seguinte erro :

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

utilizo o JBuilder2006…

Se puderem me dar uma força ! Abraço

package teste_cadastro_paciente;

import java.awt.BorderLayout;

import javax.swing.<em>;

import java.awt.FlowLayout;

import java.awt.GridLayout;

import java.awt.GridBagLayout;

import java.awt.</em>;

import java.awt.Rectangle;

import com.borland.jbcl.layout.XYLayout;

import com.borland.jbcl.layout.<em>;

import javax.swing.JTextField;

import javax.swing.JLabel;

import com.borland.dx.sql.dataset.</em>;

import java.sql.<em>;

import java.util.</em>;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import com.borland.dx.dataset.NavigationEvent;

import com.borland.dx.dataset.NavigationListener;

/**

  • <p>Title: </p>

  • <p>Description: </p>

  • <p>Copyright: Copyright © 2007</p>

  • <p>Company: </p>

  • @author not attributable

  • @version 1.0
    
    */
    
    public class Consulta_Paciente extends JFrame {
    
    XYLayout xYLayout1 = new XYLayout();
    
    JButton btnPrimeiro = new JButton();
    
    JButton btnAnterior = new JButton();
    
    JButton btnProximo = new JButton();
    
    JButton btnUltimo = new JButton();
    
    JButton btnSalvar = new JButton();
    
    JButton btnDeletar = new JButton();
    
    JButton btnAlterar = new JButton();
    
    JTextField jTextField1 = new JTextField();
    
    JLabel jLabel1 = new JLabel();
    
    JTextField jTextField2 = new JTextField();
    
    JLabel jLabel2 = new JLabel();
    
    Database database1 = new Database();
    
    QueryDataSet qryPaciente = new QueryDataSet();
    
    JButton btnLimpa = new JButton();
    
    JButton btnPesquisa = new JButton();
    
    public Consulta_Paciente() {
    
    try {
    
    jbInit();
    
    } catch (Exception exception) {
    
    exception.printStackTrace();
    
    }
    
    }
    
    private void jbInit() throws Exception {
    
    getContentPane().setLayout(xYLayout1);
    
    btnPrimeiro.setText("<<");
    
    btnProximo.setText(">");
    
    btnUltimo.setText(">>");
    
    this.setTitle(Consulta Paciente);
    
    btnSalvar.setText(Salvar);
    
    btnDeletar.setText(Excluir);
    
    btnAlterar.setText(Alterar);
    
    jLabel1.setText(Cod);
    
    jLabel2.setText(Nome);
    
    database1.setConnection(new ConnectionDescriptor(
    
    jdbc:oracle:thin:@198.17.76.3:1521:hscp, dbamv, 2930down, false,
    
    oracle.jdbc.driver.OracleDriver));
    
    btnLimpa.setText(Limpa);
    
    btnLimpa.addActionListener(new Consulta_Paciente_btnLimpa_actionAdapter(this));
    
    btnPesquisa.setText(Pesquisa);
    
    btnPesquisa.addActionListener(new
    
    Consulta_Paciente_btnPesquisa_actionAdapter(this));
    
    qryPaciente.addNavigationListener(new
    
    Consulta_Paciente_qryPaciente_navigationAdapter(this));
    
    this.getContentPane().add(btnPrimeiro, new XYConstraints(5, 4, -1, -1));
    
    this.getContentPane().add(btnAnterior, new XYConstraints(61, 4, -1, -1));
    
    this.getContentPane().add(btnProximo, new XYConstraints(109, 3, -1, -1));
    
    this.getContentPane().add(btnUltimo, new XYConstraints(156, 2, -1, -1));
    
    this.getContentPane().add(btnSalvar, new XYConstraints(212, 3, -1, -1));
    
    this.getContentPane().add(jTextField2,
    
    new XYConstraints(176, 115, 179, 24));
    
    this.getContentPane().add(jLabel2, new XYConstraints(117, 116, 56, 27));
    
    this.getContentPane().add(jLabel1, new XYConstraints(117, 59, 51, 24));
    
    this.getContentPane().add(jTextField1,
    
    new XYConstraints(176, 58, 179, 24));
    
    this.getContentPane().add(btnDeletar, new XYConstraints(281, 3, -1, -1));
    
    this.getContentPane().add(btnAlterar, new XYConstraints(351, 3, -1, -1));
    
    this.getContentPane().add(btnLimpa, new XYConstraints(5, 32, -1, -1));
    
    this.getContentPane().add(btnPesquisa, new XYConstraints(5, 61, -1, -1));
    
    btnAnterior.setText("<");
    
    }
    
    private void fazConsulta
    
    (String criterio)
    
    {
    
    String comando = "SELECT CD_ATI_MED,DS_ATI_MED FROM ATI_MED ";
    
    if (!(criterio == null||criterio.equals("")))
         comando += " WHERE CD_ATI_MED = " + criterio;
    
     qryPaciente.close();
     qryPaciente.setQuery(new QueryDescriptor (database1, comando));
     qryPaciente.open();
    
     if (qryPaciente.getRowCount() == 0)
         JOptionPane.showMessageDialog(null, "Registro não encontrado");
    
         else
             qryPaciente.first();
    

    }

    private void limpaCampos()
     {
             jTextField1.setText("");
             jTextField2.setText("");
     }
    
     private void moveCampos()
     {
         limpaCampos();
         jTextField1.setText(qryPaciente.getBigDecimal("CD_ATI_MED").toString());
         jTextField2.setText(qryPaciente.getString("DS_ATI_MED"));
    
     }
    
    public void btnLimpa_actionPerformed(ActionEvent actionEvent) {
    
    limpaCampos();
    
    }
    

    public void btnPesquisa_actionPerformed(ActionEvent actionEvent) {
    String valor = null;

    if (JOptionPane.showConfirmDialog (null, "Deseja consultar todos os registros?","Sistema",
        JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION)
    {
    
        valor = JOptionPane.showInputDialog("Digite o código do paciente");
    
        if (valor == null||valor.equals(0))
            return;
    }
    fazConsulta(valor);
    

    }

    public void qryPaciente_navigated(NavigationEvent navigationEvent) {

    moveCampos();
     btnPrimeiro.setEnabled(!qryPaciente.atFirst());
     btnAnterior.setEnabled(!qryPaciente.atLast());
     btnUltimo.setEnabled(!qryPaciente.atLast());
     btnProximo.setEnabled(!qryPaciente.atLast());
    

    }

    public void jButton1_actionPerformed(ActionEvent e) {
    
    String valor = null;
    
    fazConsulta(valor);
    
    }
    

}

class Consulta_Paciente_qryPaciente_navigationAdapter implements

NavigationListener {

private Consulta_Paciente adaptee;

Consulta_Paciente_qryPaciente_navigationAdapter(Consulta_Paciente adaptee) {

this.adaptee = adaptee;

}
public void navigated(NavigationEvent navigationEvent) {
    adaptee.qryPaciente_navigated(navigationEvent);
}

}

class Consulta_Paciente_btnPesquisa_actionAdapter implements ActionListener {

private Consulta_Paciente adaptee;

Consulta_Paciente_btnPesquisa_actionAdapter(Consulta_Paciente adaptee) {

this.adaptee = adaptee;

}
public void actionPerformed(ActionEvent actionEvent) {
    adaptee.btnPesquisa_actionPerformed(actionEvent);
}

}

class Consulta_Paciente_btnLimpa_actionAdapter implements ActionListener {

private Consulta_Paciente adaptee;

Consulta_Paciente_btnLimpa_actionAdapter(Consulta_Paciente adaptee) {

this.adaptee = adaptee;

}
public void actionPerformed(ActionEvent actionEvent) {
    adaptee.btnLimpa_actionPerformed(actionEvent);
}

}

Criado 6 de março de 2007
Respostas 0
Participantes 1