【发布时间】:2014-03-07 20:48:31
【问题描述】:
在花了很长时间弄清楚我的代码出了什么问题后,我决定继续寻求帮助。截至目前,这是导致错误的代码:
try {
ResultSet rs = statement.executeQuery("SELECT `message` FROM `notifications` WHERE `active`='1'");
List<String> messages = new ArrayList<String>();
int index = 1;
if (rs.next()) {
while (!rs.isLast()) {
messages.add(rs.getString(index));
index ++;
}
if (rs.isLast()) {
messages.add(rs.getString(index));
}
}
return messages.toArray(new String[messages.size()]);
} catch (Exception localException) {
if (localException instanceof NullPointerException) {
/* ignore for now */
localException.printStackTrace();
} else {
localException.printStackTrace();
}
}
错误告诉我该列超出范围,但当我查看我的数据库时它不是。
java.sql.SQLException: Column Index out of range, 2 > 1.
有什么建议吗?提前致谢!
【问题讨论】: