I want to add the results to the resultset and use table to display the results it's my java code
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);
}
The error shows "Column 'Janunary' not found."
I am sorry that I haven't earn sufficient reputation, so I write the result of stored procedure as follows.
categoryid January February....
1 3000 5000 (double)....
The Query code:
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');
}
Make sure the string you pass for the getDouble
function are the actual names of your SQL columns. For example, Janunary does not seem to be spelled correctly.
you skip January with your resultSet.next()
no?
maybe do resultSet.hasNext()
or equivelant and resultSet.next()
at the end of your loop?
It looks like there isn't a column named January. Is there a column named "Month" with a value of Jan/Feb/etc? If you could post the table definition and query, troubleshooting would be easier.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.