java编程:用object数组从mysql数据库中读取数据,data11[i][0] = rs.getInt(1);报错了

2024-12-16 08:49:45
推荐回答(4个)
回答1:

楼主这是数组越界啊~看看你那2维数组有没有边界值设的比较小,还有确定下 data11=new Object[rsnum][7] ;
这个rsnum是否取到了值,是多少,还有rs.next的时候赋值超没超过数组界值,错误发生在你这个文件的第41行,走个断点看看吧

回答2:

用什么二维数组啊?直接一个ArrayList!给你参考:
public ArrayList getCallLogInfo() {
ArrayList cliList = new ArrayList();
Log.d(tag, "getCallLogInfo()");
Cursor cliCursor = mContext.getContentResolver().query(
Calls.CONTENT_URI, null, null, null, Calls.DEFAULT_SORT_ORDER);
if (cliCursor != null) {
int dataCount = 0;
while (cliCursor.moveToNext()) {
CallLogInfo cli = new CallLogInfo();
dataCount++;
Log.e(tag + dataCount, "-----------------------------");

cli.setId(cliCursor.getString(cliCursor
.getColumnIndex(Calls._ID)));
cli.setCachedName(cliCursor.getString(cliCursor
.getColumnIndex(Calls.CACHED_NAME)));
cli.setCachedNumberLabel(cliCursor.getString(cliCursor
.getColumnIndex(Calls.CACHED_NUMBER_LABEL)));
cli.setCachedNumberType(cliCursor.getString(cliCursor
.getColumnIndex(Calls.CACHED_NUMBER_TYPE)));
cli.setDate(cliCursor.getString(cliCursor
.getColumnIndex(Calls.DATE)));
cli.setDuration(cliCursor.getString(cliCursor
.getColumnIndex(Calls.DURATION)));
cli.setIsNew(cliCursor.getString(cliCursor
.getColumnIndex(Calls.NEW)));
cli.setNumber(cliCursor.getString(cliCursor
.getColumnIndex(Calls.NUMBER)));
cli.setType(cliCursor.getString(cliCursor
.getColumnIndex(Calls.TYPE)));

Log.e("[CallLogList]", cli.toString());

cliList.add(cli);
}
cliCursor.close();
}
return cliList;
}

回答3:

用一维数据就可以了,没必要用二维数据,http://www.rjbus.com/zx.asp

回答4:

楼我是一个叫晶晶的女孩,前几天,我晚自习回家,被一辆大卡车撞死了,司机将我的尸体抛入了路径边的小河里,然后逃走了,你看见了这条信息后,请将她发给4个论坛,如果没有发,你的妈妈会在1个月后撞死,你的爸爸会得绝症,如果你照着做了,在5天后,你喜欢的也会喜欢你,