0

This is the method i made to load the data from MS SQL Database

private void LoadTable() {
    try {
        //making connections
        conn = MakeConnection();
        ResultSet rs = conn.createStatement().executeQuery(QueryString);

        //populating the Observable List
        while(rs.next()){
        data.add(new Customer(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6),rs.getString(7),rs.getString(8),rs.getInt(9),rs.getString(10),rs.getDouble(11),rs.getDouble(12)));
        }

        colID.setCellValueFactory(new PropertyValueFactory<>("CustomerID"));
        colFName.setCellValueFactory(new PropertyValueFactory<>("FName"));
        colMName.setCellValueFactory(new PropertyValueFactory<>("MName"));
        colLName.setCellValueFactory(new PropertyValueFactory<>("LName"));
        colEmail.setCellValueFactory(new PropertyValueFactory<>("Email"));
        colMobile.setCellValueFactory(new PropertyValueFactory<>("Mobile"));
        colAddress.setCellValueFactory(new PropertyValueFactory<>("Address"));
        colCity.setCellValueFactory(new PropertyValueFactory<>("City"));
        colZip.setCellValueFactory(new PropertyValueFactory<>("Zip"));
        colState.setCellValueFactory(new PropertyValueFactory<>("State"));
        colCredit.setCellValueFactory(new PropertyValueFactory<>("Credit"));
        colDeposit.setCellValueFactory(new PropertyValueFactory<>("Deposit"));

        tableManageCustomer.setItems(data);

    } catch (SQLException ex) {
      System.out.println(ex.toString());
    }
}

This is the Class Customer which is referenced to the previous class

    public class Customer {    
    private final IntegerProperty CustomerID;
    private final StringProperty FName;
    private final StringProperty MName;
    private final StringProperty LName;
    private final StringProperty Email;
    private final StringProperty Mobile;
    private final StringProperty Address;
    private final StringProperty City;
    private final IntegerProperty Zip;
    private final StringProperty State;
    private final DoubleProperty Credit;
    private final DoubleProperty Deposit;

    public Customer(Integer CustomerID, String FName, String MName, String LName, String Email, String Mobile, String Address, String City, Integer Zip, String State, Double Credit, Double Deposit){
    this.CustomerID=new SimpleIntegerProperty(CustomerID);
    this.FName=new SimpleStringProperty(FName);
    this.MName=new SimpleStringProperty(MName);
    this.LName=new SimpleStringProperty(LName);
    this.Email=new SimpleStringProperty(Email);
    this.Mobile=new SimpleStringProperty(Mobile);
    this.Address=new SimpleStringProperty(Address);
    this.City=new SimpleStringProperty(City);
    this.Zip=new SimpleIntegerProperty(Zip);
    this.State=new SimpleStringProperty(State);
    this.Credit=new SimpleDoubleProperty(Credit);
    this.Deposit=new SimpleDoubleProperty(Deposit);
    }

    //All Getters
    public IntegerProperty getCustomerID() {
        return CustomerID;
    }
    public StringProperty getFName() {
        return FName;
    }
    public StringProperty getMName() {
        return MName;
    }
    public StringProperty getLName() {
        return LName;
    }
    public StringProperty getEmail() {
        return Email;
    }
    public StringProperty getMobile() {
        return Mobile;
    }
    public StringProperty getAddress() {
        return Address;
    }
    public StringProperty getCity() {
        return City;
    }
    public IntegerProperty getZip() {
        return Zip;
    }
    public StringProperty getState() {
        return State;
    }
    public DoubleProperty getCredit() {
        return Credit;
    }
    public DoubleProperty getDeposit() {
        return Deposit;
    }


    //All Setters
    public void setCustomerID(Integer Value){
    CustomerID.set(Value);
    }
    public void setFName(String Value){
    FName.set(Value);
    }
    public void setMName(String Value){
    MName.set(Value);
    }
    public void setLName(String Value){
    LName.set(Value);
    }
    public void setEmail(String Value){
    Email.set(Value);
    }
    public void setMobile(String Value){
    Mobile.set(Value);
    }
    public void setAddress(String Value){
    Address.set(Value);
    }
    public void setCity(String Value){
    City.set(Value);
    }
    public void setZip(Integer Value){
    Zip.set(Value);
    }
    public void setState(String Value){
    State.set(Value);
    }
    public void setCredit(Double Value){
    Credit.set(Value);
    }
    public void setDeposit(Double Value){
    Deposit.set(Value);
    }


    //Property Values
    public IntegerProperty CustomerIDProperty(){
    return CustomerID;
    }
    public StringProperty FNameProperty(){
    return FName;
    }
    public StringProperty MNameProperty(){
    return MName;
    }
    public StringProperty LNameProperty(){
    return LName;
    }
    public StringProperty EmailProperty(){
    return Email;
    }
    public StringProperty MobileProperty(){
    return Mobile;
    }
    public StringProperty AddressProperty(){
    return Address;
    }
    public StringProperty CityProperty(){
    return City;
    }
    public IntegerProperty ZipProperty(){
    return Zip;
    }
    public StringProperty StateProperty(){
    return State;
    }
    public DoubleProperty CreditProperty(){
    return Credit;
    }
    public DoubleProperty DepositProperty(){
    return Deposit;
    } 
}

the Coonection works fine as I checked it using System.out.println() and got proper values from the database too, but as i initiate the constructor of class Customer while reading ResultSet(i.e, name rs here) it gives the following exception

Caused by: java.lang.NullPointerException
at petrolpumpsystem.CustomerFXMLController.LoadTable(CustomerFXMLController.java:225)
at petrolpumpsystem.CustomerFXMLController.initialize(CustomerFXMLController.java:214)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)

0 Answers0