我的TableView显示空行,我缺少什么?
我正在尝试从数据库中收集信息并在此列表视图中显示,jdbc连接是完美且有效的,但是tableView没有显示项目,我已经阅读了3次oracle教程但是没有运气。
public ObservableList queryChatHistory(int rowLimit) throws SQLException {
final ObservableList data = FXCollections.observableArrayList();
String query = "SELECT SERV_REC_TIMESTAMP, OWNERNAME, TEXT FROM MESSAGELOG LIMIT " + rowLimit;
Statement st = c.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next()) {
while(rs.next()) {
data.add(new MessageDataTableModel(rs.getString(1),rs.getString(2),rs.getString(3)));
}
}
return data;
}
这称为上述方法:
public void populateHistoryTable(int rowLimit) {
DAO dao = new DAO();
try {
dao.connect();
table_chathistory.setItems(dao.queryChatHistory(rowLimit));
dao.disconnect();
} catch (SQLException e) {
e.printStackTrace();
}
}
这是使用的DataModel,没有关于我遗漏的内容的想法:
private SimpleStringProperty timestamp = new SimpleStringProperty();
private SimpleStringProperty screenname = new SimpleStringProperty();
private SimpleStringProperty message = new SimpleStringProperty();
public MessageDataTableModel() {
}
public MessageDataTableModel(String timestamp, String screenname, String message) {
this.timestamp = new SimpleStringProperty(timestamp);
this.screenname = new SimpleStringProperty(screenname);
this.message = new SimpleStringProperty(message);
}
public void setTimestamp(String timestamp) {
this.timestamp.set(timestamp);
}
public void setScreenname(String screenname) {
this.screenname.set(screenname);
}
public void setMessage(String message) {
this.message.set(message);
}
}
出现空白TableView,不知道我缺少什么