How to load database data to a jtable

Asked

Viewed 44 times

0

At the time of execution appears the error message of this excerpt and I am not able to find the error. I know the connection to the bank is right because I have other classes in the same program making the connection without any error.

private void carregarGrade(){
        try{
            FornecedorDAO fornecedorDAO = new FornecedorDAO();
            FornecedorTableModel ftm = (FornecedorTableModel) jTable1.getModel();
            ftm.SetDados(fornecedorDAO.listarTodos());
        }catch(Exception ex){
            JOptionPane.showMessageDialog(this, "Erro ao carregar tabela"+ex.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
        }
    }

1 answer

0

In the visual part of Searchvendor(), in properties in the jTable model field, define property using custom code: jTable.setModel(new Vendortablemodel());

Browser other questions tagged

You are not signed in. Login or sign up in order to post.