[英]The index 0 is out of range
我在下面的try-catch塊中收到“索引0超出范圍”異常,但是我無法終生弄清楚拋出異常的位置嗎?
try{
cs = this.con.prepareCall("{call "+storedProcName+"("+procParams+")}");
for(int j = 0; j < params.length; j++){
if (paramTypes[j].equalsIgnoreCase("Int")) {
int x = 0;
try{
x = Integer.parseInt(params[j]);
} catch(Exception e) {}
cs.setInt(j, x);
} else if (paramTypes[j].equalsIgnoreCase("Boolean")) {
boolean x = false;
try{
x = (params[j].equalsIgnoreCase("True")) || (params[j].equalsIgnoreCase("T")) || (params[j].equalsIgnoreCase("1")) || (params[j].equalsIgnoreCase("Yes")) || (params[j].equalsIgnoreCase("Y"));
} catch(Exception e) {}
cs.setBoolean(j, x);
} else if (paramTypes[j].equalsIgnoreCase("String")) {
cs.setString(j, params[j]);
}
}
}catch(Exception e){
System.out.println("---------------------------------------------");
System.out.println("Problem constructing callableStatement: "+e);
System.out.println("---------------------------------------------");
}
感謝任何人看過這個,也許可以指出正確的方向!
PreparedStatement
參數的索引從1開始,而不是0。
因此,第一個參數的索引為1。如果嘗試將0用作索引,它將抱怨這不是有效的索引。
第一個參數的索引為1,而不是0
嘗試使用
System.out.println("Problem constructing callableStatement: "+e.getMessage);
找出stacktrace和“麻煩”代碼行。
} else if (paramTypes[j]
那不是params[ j ]
嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.