0

I'm trying to get the data from my SQLite database to show up in my table view; however, when I execute the code nothing is showing up and I'm receiving no errors. I believe the problem is the return value of "at" is the value location and not the actual string value. when I run the debugger it shows the value but when I .addItem(at) the value returned is: [MAAT.ahtatable@ccc143f, MAAT.ahtatable@5b4f6e4b, MAAT.ahtatable@9623c2c, MAAT.ahtatable@59335ddd, MAAT.ahtatable@3532d728]

can anyone help me through this problem

@Override
public void initialize(URL url, ResourceBundle rb) {

classCol.setCellValueFactory(
    new PropertyValueFactory<ahtatable,String>("classification"));        
thcCol.setCellValueFactory(                
    new PropertyValueFactory<ahtatable,String>("thc"));
capCol.setCellValueFactory(
    new PropertyValueFactory<ahtatable,String>("capability"));        
defCol.setCellValueFactory(
        new PropertyValueFactory<ahtatable,String>("definition"));        
scoreCol.setCellValueFactory(
    new PropertyValueFactory<ahtatable,Integer>("score"));
    objDbClass = new DBClass();
    try{
        con = objDbClass.getConnection();
        buildData();
    }catch (SQLException e){
    e.printStackTrace();
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(MainScreenController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

public void buildData(){
data = FXCollections.observableArrayList();
try{
String refresh = "SELECT * FROM HAZARD ORDER BY SCORE";
ResultSet rs = con.createStatement().executeQuery(refresh);

while(rs.next()){
        ahtatable at = new ahtatable();

        at.classified.set(rs.getString("CLASSIFICATION"));
        at.htc.set(rs.getString("HTC"));
        at.capability.set(rs.getString("EVENT"));
        at.definition.set(rs.getString("DEFINITION"));
        at.score.set(rs.getInt("SCORE"));
        data.add(at);                  
    }
    AHTAtable.setItems(data);
    System.out.println("table populated");
}catch (SQLException e) {
       e.printStackTrace();  
               System.out.println("Error on Building Data");  
    }


}

package MAAT;

import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
public class ahtatable {   


   public SimpleStringProperty classified = new SimpleStringProperty();
   public SimpleStringProperty htc = new SimpleStringProperty(); 
   public SimpleStringProperty capability = new SimpleStringProperty();
   public SimpleStringProperty definition = new SimpleStringProperty();
   public SimpleIntegerProperty score = new SimpleIntegerProperty();

   public String getclassified() {
   return classified.get();

   }

   public String getdefinition() {
   return definition.get(); 
   }

  public String gethtc() {
  return htc.get();
   }

  public String getcapability() {
  return capability.get();
    }

  public Integer getscore() {
  return score.get();
   }    
    }
B.Thompson
  • 27
  • 7
  • Using [standard naming conventions](https://en.wikipedia.org/wiki/Naming_convention_(programming)#Java) makes your code much easier for others to read, and allows it to be formatted correctly on this site (and others). In this particular case, it actually fixes the programming problem too. – James_D Apr 13 '16 at 01:12
  • how is this a duplicate question first time I asked the question? I will change the code. – B.Thompson Apr 13 '16 at 01:21
  • It is a duplicate of the existing question which is linked. The answer to that question also answers your question (as clearly as any answer that could be provided for your question). – James_D Apr 13 '16 at 01:21
  • didn't see the link at the top I will delete my post – B.Thompson Apr 13 '16 at 01:25
  • No need to delete it. It will act as a "signpost" to the existing answer, and is useful for others for that purpose. – James_D Apr 13 '16 at 01:26
  • thanks for the assistance. – B.Thompson Apr 13 '16 at 01:27
  • yw. You might want to upvote the other answer if it is helpful for you. – James_D Apr 13 '16 at 01:30

0 Answers0