0
I have to fill out a table with bank data. But nothing appears at all.
My Class
Inserting information in the table:
DefaultTableModel dtm = new DefaultTableModel();
String sql = "select * from eventos";
ResultSet rs = null;
try {
rs = stmt.executeQuery(query);
} catch (SQLException ex) {
Logger.getLogger(folha.class.getName()).log(Level.SEVERE, null, ex);
}
try {
while (rs.next()) {
//pega os valores do bd para popular tabela
dtm.addRow(new String[] {rs.getString("codEvento"), rs.getString("descricaoEvento"), rs.getString("referencia"), rs.getString("vencimento"), rs.getString("desconto") });
}
}catch (SQLException ex) {
Logger.getLogger(folha.class.getName()).log(Level.SEVERE, null, ex);
}
Read this one too: How popular a Jtable with its own Tablemodel?
– user28595
If you read the accepted answer of these two questions, you will be more than able to do what you intend.
– user28595
The data comes from the database...
– alexjosesilva
The first question has the answer to this. The second I teach step by step how to "model" the table according to the "taste",
– user28595