title: Display Oracle Database content in JavaFX TableView
body: <p>I want to display content of an Oracle Database in my TableView "FilmTable".
  The structure of the Oracle Databade is: a table column named "FILMTITEL" in the table "LUKA1". The are 4 Film names like Fast and Furious, ...</p>
  
  <p>Hope you can help me and i hope i understand your Solutions to solve my Problem.</p>
  
  <p>I made this code and i got this Errors:</p>
  
  <pre><code>    javafx.fxml.LoadException: 
  /D:/Users/muellerl/workspace/Table_DB/bin/application/gui.fxml
  
      at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source)
      at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
      at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
      at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
      at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
      at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
      at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
      at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
      at javafx.fxml.FXMLLoader.load(Unknown Source)
      at application.Main.start(Main.java:15)
      at com.sun.javafx.application.LauncherImpl$8.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl$7.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl$6$1.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl$6$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl$6.run(Unknown Source)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$300(Unknown Source)
      at com.sun.glass.ui.win.WinApplication$4$1.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  Caused by: java.lang.NullPointerException
      at controller.table_controller.initialize(table_controller.java:39)
      ... 20 more
  </code></pre>
  
  <p>If I remove all Table-Code-Contents the error isn't there.</p>
  
  <p>Here is my code i hope you can help me to Display this things.</p>
  
  <p>Main.java</p>
  
  <pre><code>    package application;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.stage.Stage;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.scene.layout.BorderPane;
  
  
  public class Main extends Application {
      @Override
      public void start(Stage primaryStage) {
          try {
              Parent root = FXMLLoader.load(getClass().getResource(
                      "/application/gui.fxml"));
              Scene scene = new Scene(root,400,400);
              scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
              primaryStage.setScene(scene);
              primaryStage.show();
          } catch(Exception e) {
              e.printStackTrace();
          }
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>
  
  <p>table_controller.java:</p>
  
  <pre><code>package controller;
  
  import java.net.URL;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.sql.Statement;
  import java.util.ResourceBundle;
  
  import oracle.jdbc.*;
  import model.filmtable_data;
  import javafx.collections.FXCollections;
  import javafx.collections.ObservableList;
  import javafx.fxml.FXML;
  import javafx.fxml.Initializable;
  import javafx.scene.control.TableColumn;
  import javafx.scene.control.TableView;
  import javafx.scene.control.cell.PropertyValueFactory;
  
  public class table_controller implements Initializable {
      Connection conn;
      String output;
      int zaehler = 0;
  
      @FXML
      private TableView&lt;filmtable_data&gt; FilmTable;
      @FXML
      private TableColumn&lt;filmtable_data, String&gt; Filmtitel_col;
      @FXML
      private TableColumn&lt;filmtable_data, Integer&gt; ID_col;
  
  
  
      @Override
      public void initialize(URL location, ResourceBundle resources) {
          // Observable List
          final ObservableList&lt;filmtable_data&gt; data = FXCollections.observableArrayList();
          ID_col.setCellValueFactory(new PropertyValueFactory&lt;filmtable_data, Integer&gt;("rID"));
          Filmtitel_col.setCellValueFactory(new PropertyValueFactory&lt;filmtable_data, String&gt;("rFilmtitel"));
          try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
          } catch (ClassNotFoundException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
          }
          try {
              Connection conn = DriverManager.getConnection("jdbc:oracle:thin:lukas/1234@10.140.79.39:1521:OTTO");
              Statement statement = conn.createStatement();
              ResultSet resultset = statement.executeQuery("SELECT FILMTITEL FROM LUKA1");
  
              while (resultset.next()) {
                  output = resultset.getString(1);
                  zaehler++;
                  filmtable_data entry = new filmtable_data(zaehler, output);
                  data.add(entry);
                  System.out.println (resultset.getString(1));
                  System.out.println(output);
                  }
              FilmTable.setItems(data);
              statement.close();
          }   catch (SQLException e) {
                  System.out.println("Login fehlgeschlagen.");
                  e.printStackTrace();
          }
      }   
  }
  </code></pre>
  
  <p>filmtable_data.java:</p>
  
  <pre><code>package model;
  
  import javafx.beans.property.SimpleIntegerProperty;
  import javafx.beans.property.SimpleStringProperty;
  
  public class filmtable_data {
  
      private final SimpleIntegerProperty rID;
      private final SimpleStringProperty rFilmtitel;
  
      public filmtable_data (Integer sID, String sFilmtitel) {
          this.rID = new SimpleIntegerProperty(sID);
          this.rFilmtitel = new SimpleStringProperty(sFilmtitel);
      }
  
      public Integer getRID() {
          return rID.get();
      }
  
      public void setRID(int set) {
          rID.set(set);
      }
  
      public String getRFilmtitel() {
          return rFilmtitel.get();
      }
  
      public void setRFilmtitel(String set) {
          rFilmtitel.set(set);
      }
  }
  </code></pre>