Popular Jtable with BD data without using Defaulttablemodel

Asked

Viewed 87 times

0

I’m doing a whole layered project and I read somewhere that the use of Defaulttablemodel is not very recommended. I am trying to receive values registered in the BD and fill a jTable with these values. Below follow the classes defined.

DAO Layer Method to List Registered Persons:

 public List listarTodas() throws SQLException, ClassNotFoundException {

   List lista;
   try (Connection conn = ConnectionFactory.getConnectionFactory()) {
     lista = new ArrayList();
     String sql = "SELECT * FROM Pessoa";
     try (PreparedStatement st = conn.prepareStatement(sql)) {
         ResultSet rs = st.executeQuery();
         while (rs.next()) {
             Pessoa p = resultSet2Model(rs);
             lista.add(p);
         }
     }
}
    return lista;

}

I believe that now one should implement the Business and View Layers. That’s not it?

  • Fircar recreating the same doubt does not help much. Do what I suggested in the other question, edit and provide a [mcve] so that your problem can be better analyzed.

  • I apologize.

  • I added a new question in duplicates, read it. It shows how to create a model for table.

  • Thank you very much. How should I proceed next ? It is possible to use an already asked question to do another?

  • Ever read it? Already tested the tip there? First try to do as explained. Otherwise it will be duplicate again. Try to read calmly, make a simpler example, and then apply in your program. If painting doubts about something there, then you ask here.

No answers

Browser other questions tagged

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