javase代码有错,谁能调试?
String date = date_textfield.getText();
String days = days_textfield.getText();
String period = period_textfield.getText();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date toDate = sdf.parse(date);
Calendar calendar = Calendar.getInstance();
calendar.setTime(toDate);
calendar.add(Calendar.DATE, -1*Integer.valueOf(days));
Date fromDate = calendar.getTime();
List<Object[]> view = new ArrayList<Object[]>();
for (int i=0; i<Integer.valueOf(period); i++) {
String sql = "select * from your_table where field between ? and ?";
PreparedStatement ps = your_connection.prepareStatement(sql);
ps.setDate(1, fromDate);
ps.setDate(2, toDate);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
List<Object> row = new ArrayList<Object>();
for (int i=0; i<rs.getMetaData().getColumnCount()) {
row.add(rs.getObject(i));
}
view.add(row);
}
calendar.add(Calendar.DATE, -1);
fromDate = calendar.getTime();
}
for (int i=0; i<view.size(); i++) {
for (int j=0; j<view.get(i).length; j++) {
your_jtable.setValueAt(view.get(i)[j], i, j);
}
}
------解决方案--------------------
List<Object[]> view = new ArrayList<Object[]>();//这里面的
view里面装的是数组
List<Object> row = new ArrayList<Object>();
row是list
view.add(row)错了吧
把 row 转换为数组吧 或者其他怎么着自己看着办吧