请问如何将数据库中得到的数据写入table中?
table的定义代码如下:
changShangXinXiTable.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"厂商编号", "厂商名称", "应付款金额", "预付款金额", "实际欠款", "联系人", "联系电话", "邮政编码", "通信地址", "入档日期"
}
) {
boolean[] canEdit = new boolean [] {
false, false, false, false, false, false, false, false, false, false
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
链接数据库代码如下
try{
result = db.executeQuery(SQLString);
while (result.next()){
//这里就加入取数据库中数据和设置table值的代码
}
}
catch(java.sql.SQLException se){}
要求是,当有多条数据符合查询条件的话把所有符合的行都显示在table中
谢谢了!