java.lang.String 不能强制转换为 [Ljava.lang.String;
2022-09-02 10:32:34
我有以下内容,但我收到错误
java.lang.String 不能强制转换为 [Ljava.lang.String;
我已将 更改为,因为我遇到了下一个错误:Object[]
String[]
java.lang.Object 不能被强制转换为 [Ljava.lang.String;
有什么想法吗?
private Collection queryStatement(String SelectStatement) {
int colcount = 0;
int rowcount = 0;
int rowcounter = 0;
ArrayList a = new ArrayList();
Query query = getEntityManager().createNativeQuery(SelectStatement);
List<String[]> resultList = (List<String[]>) query.getResultList();
if (!resultList.equals(Collections.emptyList())) {
rowcount = resultList.size();
}
if (rowcount > 0) {
colcount = ((String[]) query.getResultList().get(0)).length;
}
rows = rowcount;
cols = colcount;
String[][] array = new String[rowcount][colcount];
for (String[] obj : resultList) {
String[] record = new String[colcount];
for (int colCounter = 0; colCounter < colcount; colCounter++) {
record[colCounter] = safeValue(obj[colCounter]+"");
}
array[ rowcounter++] = (String[]) record;
}
a.add(array);
return a;
}