After hours and hours of trying i'm getting close to my deadline for a project and still haven't gotten any solution for my rather easy problem. I need to fill a tableview with data from SQL Query but I can't get it to work even if i copy paste online examples... I need the same result as the following code
public DefaultTableModel buildTableModel() {
ResultSetMetaData metaData;
try (Connection conn = DriverManager.getConnection(MapperConfig.JDBC_URL)) {
PreparedStatement queryOpgeslagenGames = conn.prepareStatement("");
ResultSet rs = queryOpgeslagenGames.executeQuery("SELECT spellen.spelID, spellen.spelNaam AS 'Naam van Spel', group_concat( naam separator ', ') AS 'Deelnemende spelers' FROM spellen RIGHT JOIN spelers ON spellen.spelID = spelers.spelID GROUP BY spellen.spelID");
metaData = rs.getMetaData();
// names of columns
Vector<String> columnNames = new Vector<String>();
int columnCount = metaData.getColumnCount();
for (int column = 1; column <= columnCount; column++) {
columnNames.add(metaData.getColumnName(column));
}
// data of the table
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
while (rs.next()) {
Vector<Object> vector = new Vector<Object>();
for (int columnIndex = 1; columnIndex <= columnCount; columnIndex++) {
vector.add(rs.getObject(columnIndex));
}
data.add(vector);
}
return new DefaultTableModel(data, columnNames);
} catch (SQLException ex) {
for (Throwable t : ex) {
t.printStackTrace();
}
}
return new DefaultTableModel();
}
but since i need to use it in JavaFX i can't use Jtable and need to use table view. Can someone convert the code for me? or tell me how to use DefaultTableModel to make a table view?
The table wil always have 3 colums, first being the gameID, second the game save file name and third a collection of names from the people in the game.