I'm doing an entire project in layers and read somewhere that using DefaultTableModel is not very recommended. I am trying to receive values registered in the DB and fill a jTable with those values. Below are the defined classes.
DAO Layer method to list People registered:
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 you should now implement the Business and View layers. Is not that it?