@@ -0,0 +1,2302 @@
+/*%0A * Copyright (c) 2017 Falko Schumann%0A * Released under the terms of the MIT License.%0A */%0A%0Apackage de.muspellheim.jdbc;%0A%0Aimport com.mysql.jdbc.jdbc2.optional.*;%0Aimport javafx.application.*;%0Aimport javafx.beans.property.*;%0Aimport javafx.beans.value.*;%0Aimport javafx.collections.*;%0Aimport javafx.scene.*;%0Aimport javafx.scene.control.*;%0Aimport javafx.stage.*;%0Aimport javafx.util.*;%0A%0Aimport java.sql.*;%0A%0Apublic class FXApplication extends Application %7B%0A%0A    @Override%0A    public void start(Stage stage) throws Exception %7B%0A        TableView tableView = new TableView();%0A%0A        MysqlDataSource dataSource = new MysqlConnectionPoolDataSource();%0A        dataSource.setPort(8889);%0A        dataSource.setUser(%22root%22);%0A        dataSource.setPassword(%22root%22);%0A        dataSource.setDatabaseName(%22oshop%22);%0A%0A        ObservableList%3CObservableList%3E data = FXCollections.observableArrayList();%0A        try (Connection connection = dataSource.getConnection()) %7B%0A            String sql = %22SELECT artikel_id AS 'Artikel-ID', bezeichnung AS 'Bezeichnung', CONCAT(FORMAT(einzelpreis, 2, 'de_DE'), ' ', waehrung) AS 'Einzelpreis' FROM artikel WHERE deleted = 0%22;%0A            ResultSet resultSet = connection.createStatement().executeQuery(sql);%0A%0A            for (int i = 0; i %3C resultSet.getMetaData().getColumnCount(); i++) %7B%0A                final int j = i;%0A                TableColumn col = new TableColumn(resultSet.getMetaData().getColumnLabel(i + 1));%0A                col.setCellValueFactory((Callback%3CTableColumn.CellDataFeatures%3CObservableList, String%3E, ObservableValue%3CString%3E%3E) param -%3E new SimpleStringProperty(param.getValue().get(j).toString()));%0A                tableView.getColumns().addAll(col);%0A            %7D%0A%0A            while (resultSet.next()) %7B%0A                ObservableList%3CString%3E row = FXCollections.observableArrayList();%0A                for (int i = 1; i %3C= resultSet.getMetaData().getColumnCount(); i++) %7B%0A                    row.add(resultSet.getString(i));%0A                %7D%0A                data.add(row);%0A            %7D%0A        %7D catch (SQLException ex) %7B%0A            ex.printStackTrace();%0A        %7D%0A        tableView.setItems(data);%0A%0A        Scene scene = new Scene(tableView);%0A%0A        stage.setTitle(%22Demo with table kunde%22);%0A        stage.setScene(scene);%0A        stage.show();%0A    %7D%0A%0A%7D%0A

Create dynamic table with result set