从数据库获取所有记录到Vaadin表
问题描述:
我试图从数据库表中加载记录到Vaadin表。从数据库获取所有记录到Vaadin表
我得到的所有记录从表process
这样的:
public ResultSet selectRecordsFromDbUserTable() throws SQLException {
Connection dbConnection = null;
Statement statement = null;
ResultSet rs = null;
String selectTableSQL = "SELECT * from process";
try {
dbConnection = getDBConnection();
statement = dbConnection.createStatement();
System.out.println(selectTableSQL);
// execute select SQL stetement
rs = statement.executeQuery(selectTableSQL);
} catch (SQLException e) {
System.out.println(e.getMessage());
} finally {
if (statement != null) {
statement.close();
}
if (dbConnection != null) {
dbConnection.close();
}
}
return rs;
}
而且它运作良好。在ResultSet rs
我得到我需要的所有行。
如何将它们加载到Vaadin Table
?
答
首先通过ResultSet
int itemId=1;
while(rs.next()){
table.addItem(new Object[]{rs.getLong("id"),rs.getString("name")},itemId++);
}
做得好添加容器性能
循环!完美的作品 – ilovkatie 2014-10-06 13:18:42