I have two different classes with a method inside each. Classes are 'DBConnect' and 'Controller'. Since I try to build an fx application I have a combobox named as 'privilageBox' and a generic type named 'privilageList' for its choices (inside Controller class).
ObservableList<String> privilageList = FXCollections.observableArrayList("Admin","Employee");
There is a function called 'login' inside the same class and there is some coding inside it. I have an if statement as well and what I am trying to do inside the requirements section is I try to call 'checkUser' method that is located inside the DBConnect class and set its parameters.
DBConnect lg = new DBConnect();
if(lg.checkUser(textField1.getText(),passwordField1.getText(),(privilageBox.getValue()).toString()))
This is where I get the NullPointerException. I am setting the paremeters wrong and I ran out of solutions.
Here is the checkUser function's parameters inside DBConnect class:
public boolean checkUser(String username, String password,String privilage) throws SQLException
I have tried to set the parameters for 'checkUser' and if statement inside 'login' as below:
public boolean checkUser(String username, String password,ObservableList privilage) throws SQLException
if(lg.checkUser(textField1.getText(),passwordField1.getText(),privilageList.toString))
It did not work also. By the way, this is a runtime error. I get no errors at compile time. Error message (discarded unnecessary parts):
Caused by: java.lang.NullPointerException
at sample.DBConnect.checkUser(DBConnect.java:70)
at sample.Controller.login(Controller.java:44)