我想将结果添加到结果集并使用表来显示结果 这是我的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);
}
错误显示“未找到列'Janunary'。”
对不起,我没有获得足够的声誉,所以我按如下方式写了存储过程的结果。
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');
}
答案 0 :(得分:0)
确保为getDouble
函数传递的字符串是SQL列的实际名称。例如, Janunary 似乎拼写不正确。
答案 1 :(得分:0)
您在{1}}没有?
的情况下跳过1月份在循环结束时可能会resultSet.next()
或等效,resultSet.hasNext()
吗?
答案 2 :(得分:0)
看起来没有名为January的列。是否有一个名为“Month”的列,其值为Jan / Feb / etc?如果您可以发布表定义和查询,则可以更轻松地进行故障排除。