我在获取结果集时遇到以下错误。我正在使用jdbc瘦驱动程序( ojdbc6 )。有趣的是,它在处理 10行后给出了错误。我查了一些论坛,发现jdbc驱动有一些问题。我想知道我是否可以用这个驱动程序(ojdbc6)本身做点什么!!
非常感谢您提供的任何帮助。
这是表结构:
CREATE TABLE "TEST_SO_MANY_COLUMNS"
( "COL1" VARCHAR2(4000 BYTE),
"COL2" VARCHAR2(4000),
"COL3" VARCHAR2(4000),
"COL4" VARCHAR2(4000),
"COL5" VARCHAR2(4000),
"COL6" VARCHAR2(4000),
"COL7" VARCHAR2(4000),
"COL8" VARCHAR2(4000),
"COL9" VARCHAR2(4000),
"COL10" VARCHAR2(4000),
"COL11" VARCHAR2(4000),
"COL12" VARCHAR2(4000),
"COL13" VARCHAR2(4000),
"COL14" VARCHAR2(4000),
"COL15" VARCHAR2(4000),
"COL16" VARCHAR2(4000),
"COL17" VARCHAR2(4000),
"COL18" VARCHAR2(4000),
"COL19" VARCHAR2(4000),
"COL20" VARCHAR2(4000),
"COL21" VARCHAR2(4000),
"COL22" VARCHAR2(4000),
"COL23" VARCHAR2(4000),
"COL24" VARCHAR2(4000),
"COL25" VARCHAR2(4000),
"COL26" VARCHAR2(4000),
"COL27" VARCHAR2(4000),
"COL28" VARCHAR2(4000),
"COL29" VARCHAR2(4000),
"COL30" VARCHAR2(4000),
"COL31" VARCHAR2(4000),
"COL32" VARCHAR2(4000),
"COL33" VARCHAR2(4000),
"COL34" VARCHAR2(4000),
"COL35" VARCHAR2(4000),
"COL36" VARCHAR2(4000),
"COL37" VARCHAR2(4000),
"COL38" VARCHAR2(4000),
"COL39" VARCHAR2(4000),
"COL40" VARCHAR2(4000),
"COL41" VARCHAR2(4000),
"COL42" VARCHAR2(4000),
"COL43" VARCHAR2(4000),
"COL44" VARCHAR2(4000),
"COL45" VARCHAR2(4000),
"COL46" VARCHAR2(4000),
"COL47" VARCHAR2(4000),
"COL48" VARCHAR2(4000),
"COL49" VARCHAR2(4000),
"COL50" VARCHAR2(4000),
"COL51" VARCHAR2(4000),
"COL52" VARCHAR2(4000),
"COL53" VARCHAR2(4000),
"COL54" VARCHAR2(4000),
"COL55" VARCHAR2(4000),
"COL56" VARCHAR2(4000),
"COL57" VARCHAR2(4000),
"COL58" VARCHAR2(4000),
"COL59" VARCHAR2(4000),
"COL60" VARCHAR2(4000),
"COL61" VARCHAR2(4000),
"COL62" VARCHAR2(4000),
"COL63" VARCHAR2(4000),
"COL64" VARCHAR2(4000),
"COL65" VARCHAR2(4000),
"COL66" VARCHAR2(4000),
"COL67" VARCHAR2(4000),
"COL68" VARCHAR2(4000),
"COL69" VARCHAR2(4000),
"COL70" VARCHAR2(4000),
"COL71" VARCHAR2(4000),
"COL72" VARCHAR2(4000),
"COL73" VARCHAR2(4000),
"COL74" VARCHAR2(4000),
"COL75" VARCHAR2(4000),
"COL76" VARCHAR2(4000),
"COL77" VARCHAR2(4000),
"COL78" VARCHAR2(4000),
"COL79" VARCHAR2(4000),
"COL80" VARCHAR2(4000),
"COL81" VARCHAR2(4000),
"COL82" VARCHAR2(4000),
"COL83" VARCHAR2(4000),
"COL84" VARCHAR2(4000),
"COL85" VARCHAR2(4000),
"COL86" VARCHAR2(4000),
"COL87" VARCHAR2(4000),
"COL88" VARCHAR2(4000),
"COL89" VARCHAR2(4000),
"COL90" VARCHAR2(4000),
"COL91" VARCHAR2(4000),
"COL92" VARCHAR2(4000),
"COL93" VARCHAR2(4000),
"COL94" VARCHAR2(4000),
"COL95" VARCHAR2(4000),
"COL96" VARCHAR2(4000),
"COL97" VARCHAR2(4000),
"COL98" VARCHAR2(4000),
"COL99" VARCHAR2(4000),
"COL100" VARCHAR2(4000),
"COL101" VARCHAR2(4000),
"COL102" VARCHAR2(4000),
"COL103" VARCHAR2(4000),
"COL104" VARCHAR2(4000),
"COL105" VARCHAR2(4000),
"COL106" VARCHAR2(4000),
"COL107" VARCHAR2(4000),
"COL108" VARCHAR2(4000),
"COL109" VARCHAR2(4000),
"COL110" VARCHAR2(4000),
"COL111" VARCHAR2(4000),
"COL112" VARCHAR2(4000),
"COL113" VARCHAR2(4000),
"COL114" VARCHAR2(4000),
"COL115" VARCHAR2(4000),
"COL116" VARCHAR2(4000),
"COL117" VARCHAR2(4000),
"COL118" VARCHAR2(4000),
"COL119" VARCHAR2(4000),
"COL120" VARCHAR2(4000)
);
表有大约200行,所有列的值最多为4000个字符。
查询格式:
select "COL1","COL2","COL3" ......."COL120" from SRC."TEST_SO_MANY_COLUMNS"
代码段:
Statement sel_stmt = connection.createStatement();
ResultSet res = sel_stmt.executeQuery(query);
res.setFetchSize(10000);
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
获取resultSet时没有收到任何错误。迭代结果集时会出现问题:
int count = 0;
if (resultSet.next()) {
count++ ;
//Do Something i.e. resultSet.getObject() .. and so on..
}
// Do something
上面的迭代适用于前10行,但在此之后给出了以下异常。堆栈错误的痕迹:
java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at oracle.jdbc.driver.T4CVarcharAccessor.saveDataFromOldDefineBuffers(T4CVarcharAccessor.java:411)
at oracle.jdbc.driver.T4CStatement.saveDefineBuffersIfRequired(T4CStatement.java:533)
at oracle.jdbc.driver.OracleStatement.prepareAccessors(OracleStatement.java:1070)
at oracle.jdbc.driver.OracleStatement.check_row_prefetch_changed(OracleStatement.java:3080)
at oracle.jdbc.driver.OracleResultSetImpl.close_or_fetch_from_next(OracleResultSetImpl.java:321)
at oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java:277)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
答案 0 :(得分:0)
这是一个很老的错误(4751145)。它在2005年的10.2驱动程序中报道。 10.2.0.3驱动程序有修复。我的猜测是你用10.2.0.1或10.2.0.2运行。
Oracle下载页面在这里: http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
如果您想坚持使用10.2代码行,那么您应该转到最新的10.2.0.5补丁集。请注意,驱动程序是向后兼容的,因此您也可以使用11.2或甚至12.1驱动程序连接到10g数据库。