JTable与数据库

04-08-25 qiubaoning
我用的AbstractTableModel,下面是一些代码:

int count=0;

rs.previous();

while (rs.next()) {

count++;

}

rs.first();

for (int a = 1; a <=count; a++) {

for (int n = 0; n < j; n++) {

simpleRow.addElement(rs.getString(n+1));

}

totalRows.addElement(simpleRow);

rs.next();

}

其中j是列数,为什么我通过JTable显示出来的只是一行的重复呢?

还请指教,谢谢!

SportsBaby1980
2004-09-08 16:36

int count=0;
rs.previous();
while (rs.next()) {
count++;
}
rs.first();
for (int a = 1; a <=count; a++) {
//在这里 simpleRow = new ();
//可以试一下
for (int n = 0; n < j; n++) {
 simpleRow.addElement(rs.getString(n+1));
}
totalRows.addElement(simpleRow);
rs.next();

<p>

猜你喜欢