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();
}
}