我想将结果添加到结果集中并使用表来显示结果,这是我的 java 代码
while (resultSet.next()) {
Object[] objects = {
resultSet.getDouble("January"),
resultSet.getDouble("February"),
resultSet.getDouble("March"),
resultSet.getDouble("April"),
resultSet.getDouble("May"),
resultSet.getDouble("June"),
resultSet.getDouble("July"),
resultSet.getDouble("August"),
resultSet.getDouble("September"),
resultSet.getDouble("October"),
resultSet.getDouble("November"),
resultSet.getDouble("December"),
};
model.addRow(objects);
}
错误显示“未找到列 '一月'”。
很抱歉我没有获得足够的声誉,所以我将存储过程的结果写如下。
categoryid January February....
1 3000 5000 (double)....
查询代码:
CallableStatement callableStatement = connection.prepareCall(sql);
if (cobAccount.getSelectedIndex() != 0) {
String accountid = cobAccount.getSelectedItem().toString()
.substring(0, 1);
callableStatement.setString(1, accountid);
} else {
callableStatement.setString(1, "0");
}
if (cobYear.getSelectedIndex() != 0) {
String year = cobYear.getSelectedItem().toString();
callableStatement.setString(2, year);
} else {
callableStatement.setString(2, "0");
}
if (cobMember.getSelectedIndex() != 0) {
String memberid = cobMember.getSelectedItem().toString()
.substring(0, 1);
callableStatement.setString(3, memberid);
} else {
callableStatement.setString(3, "0");
}
if (!"".equals(txtMinmoney.getText())) {
double minMoney = Double.valueOf(txtMaxmoney.getText());
callableStatement.setDouble(4, minMoney);
} else {
callableStatement.setDouble(4, '0');
}
if (!"".equals(txtMaxmoney.getText())) {
double maxMoney = Double.valueOf(txtMaxmoney.getText());
callableStatement.setDouble(5, maxMoney);
} else {
callableStatement.setDouble(5, '0');
}