Morning all, I'm new to java and running into an issue. I'm building a tableView based on a friend's code which is working however when I try to do it I get the error "Error:java.lang.RuntimeException: Exception in Application start method" it only happens when I have the code below. If I deleted it, the application runs.
Main Class:
TableView<tableClass> tableView = new TableView<tableClass>();
ResultSet RtnRS = dataBase.GetCars();
List<String> Registration = new ArrayList<String>();
List<String> Manufacturer = new ArrayList<String>();
List<String> Model = new ArrayList<String>();
List<String> Engine = new ArrayList<String>();
List<String> Description = new ArrayList<String>();
List<String> Type = new ArrayList<String>();
String RegOut = RtnRS.getString("registration");
Registration.add(RegOut);
String ManOut = RtnRS.getString("manufacturer");
Manufacturer.add(ManOut);
String ModOut = RtnRS.getString("model");
Model.add(ModOut);
String EngOut = RtnRS.getString("engine");
Engine.add(EngOut);
String DesOut = RtnRS.getString("description");
Description.add(DesOut);
String TypOut = RtnRS.getString("type");
Type.add(TypOut);
for (int i = 0; i < Registration.size();i++) {
tableView.getItems().add(new tableClass(Registration.get(i), Manufacturer.get(i), Model.get(i), Engine.get(i), Description.get(i), Type.get(i)));
}
TableColumn<tableClass, String> column1 = new TableColumn<>("Registration");
column1.setCellValueFactory(new PropertyValueFactory<>("Registration"));
TableColumn<tableClass, String> column2 = new TableColumn<>("Manufacturer");
column2.setCellValueFactory(new PropertyValueFactory<>("Manufacturer"));
TableColumn<tableClass, String> column3 = new TableColumn<>("Model");
column3.setCellValueFactory(new PropertyValueFactory<>("Model"));
TableColumn<tableClass, String> column4 = new TableColumn<>("Engine");
column4.setCellValueFactory(new PropertyValueFactory<>("Engine"));
TableColumn<tableClass, String> column5 = new TableColumn<>("Description");
column5.setCellValueFactory(new PropertyValueFactory<>("Description"));
TableColumn<tableClass, String> column6 = new TableColumn<>("Type");
column5.setCellValueFactory(new PropertyValueFactory<>("Type"));
// Add columns to table
tableView.getColumns().add(column1);
tableView.getColumns().add(column2);
tableView.getColumns().add(column3);
tableView.getColumns().add(column4);
tableView.getColumns().add(column5);
tableView.getColumns().add(column6);
tableClass:
public class tableClass {
private String Registration = null;
private String Manufacturer = null;
private String Model = null;
private String Engine = null;
private String Description = null;
private String Type = null;
public tableClass(String Registration, String Manufacturer, String Model, String Engine, String Description, String Type) {
this.Registration = Registration;
this.Manufacturer = Manufacturer;
this.Model = Model;
this.Engine = Engine;
this.Description = Description;
this.Type = Type;
}
public String getReg() {
return Registration;
}
public void setReg(String Registration) {
this.Registration = Registration;
}
public String getMan() {
return Manufacturer;
}
public void setMan(String Manufacturer) {
this.Manufacturer = Manufacturer;
}
public String getMod() {
return Model;
}
public void setMod(String Model) {
this.Model = Model;
}
public String getEng() {
return Engine;
}
public void setEng(String Engine) {
this.Engine = Engine;
}
public String getDes() {
return Description;
}
public void setDes(String Description) {
this.Description = Description;
}
public String getTyp() {
return Type;
}
public void setTyp(String Type) {
this.Type = Type;
}
}
Stack Trace
PS C:\Users\maxmc\OneDrive\Desktop\Mck Hire JavaFX\MckHireJavaFX> c:; cd 'c:\Users\maxmc\OneDrive\Desktop\Mck Hire JavaFX\MckHireJavaFX'; & 'C:\Program Files\Eclipse Adoptium\jdk-17.0.2.8-hotspot\bin\java.exe' '--module-path' 'C:/Users/maxmc/OneDrive/Documents/openjfx-18_windows-x64_bin-sdk/javafx-sdk-18/lib' '--add-modules' 'javafx.controls,javafx.fxml' '-XX:+ShowCodeDetailsInExceptionMessages' '@C:\Users\maxmc\AppData\Local\Temp\cp_16o1mso8ggtiyi1capztdqsfl.argfile' 'App'
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Database is connected !Exception in Application start method
Do not connect to DB - Error:java.lang.RuntimeException: Exception in Application start method