起因
SQL 查询 时携带了超过8个参数以后 一直提示下标越界
原因
我用的 Oracle11g JDBC 驱动是网上随便下的 oracle 11.1.0.7.0-Produc tion 的 ojdbc6.jar 自己丢到本地Maven上
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| case 13: { if (count > 0) { if (this.parameterList == OracleSql.EMPTY_LIST) { this.parameterList = new String[8]; } else if (this.parameterList.length <= this.parameterCount) { final String[] parameterList = new String[this.parameterList.length * 4]; System.arraycopy(this.parameterList, 0, parameterList, 0, this.parameterList.length); this.parameterList = parameterList; } this.parameterList[this.parameterCount] = new String(this.currentParameter, 0, count).intern(); count = 0; ++this.parameterCount; break; } break; }
|
更换为Maven 仓库中的最新版
com.oracle.database.jdbc
ojdbc6
11.2.0.4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| case 16: { if (count <= 0) { break; } if (this.parameterList == OracleSql.EMPTY_LIST) { this.parameterList = new String[Math.max(8, this.parameterCount * 4)]; } else if (this.parameterList.length <= this.parameterCount) { final String[] parameterList = new String[this.parameterList.length * 4]; System.arraycopy(this.parameterList, 0, parameterList, 0, this.parameterList.length); this.parameterList = parameterList; } this.parameterList[this.parameterCount] = new String(this.currentParameter, 0, count).intern(); count = 0; ++this.parameterCount; if (n != 0) { ++this.returningIntoParameterCount; break; } break; }
|
可以看到
1 2 3 4 5
| this.parameterList = new String[8];
this.parameterList = new String[Math.max(8, this.parameterCount * 4)];
|
Oracle Jdbc 驱动竟然还会有这么明显的BUG… emm
总结
驱动老老实实用最新的