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.
– user28595
I apologize.
– elbenevides
I added a new question in duplicates, read it. It shows how to create a model for table.
– user28595
Thank you very much. How should I proceed next ? It is possible to use an already asked question to do another?
– elbenevides
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.
– user28595