欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ORALCE10g驱动classes12.jar版本问题 类型长度大于最大值

程序员文章站 2022-05-25 22:53:52
...
参考资料:[url]http://xiaobo.iteye.com/blog/44466[/url]
创建存储过程返回游标集
获得Connection调用prepareCall方法 报如下错误
java.sql.SQLException: 类型长度大于最大值

oracle.jdbc.OracleCallableStatement csmt = null;
csmt = (oracle.jdbc.OracleCallableStatement)conn.prepareCall("{call t(?,?,?)}");
csmt.setString(1,'');
csmt.setString(2,'');
csmt.registerOutParameter(3, oracle.jdbc.OracleTypes.CURSOR);
csmt.execute();
ResultSet rs = csmt.getCursor(3);


如下异常:
java.sql.SQLException: 类型长度大于最大值
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
at oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:884)
at oracle.jdbc.driver.T4CMAREngine.buffer2Value(T4CMAREngine.java:2230)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB4(T4CMAREngine.java:1146)
at oracle.jdbc.driver.T4CMAREngine.unmarshalDALC(T4CMAREngine.java:2097)
at oracle.jdbc.driver.T4C8TTIuds.unmarshal(T4C8TTIuds.java:127)
at oracle.jdbc.driver.T4CTTIdcb.receiveCommon(T4CTTIdcb.java:125)
at oracle.jdbc.driver.T4CTTIdcb.receiveFromRefCursor(T4CTTIdcb.java:103)
at oracle.jdbc.driver.T4CResultSetAccessor.unmarshalOneRow(T4CResultSetAccessor.java:165)
at oracle.jdbc.driver.T4CTTIrxd.unmarshal(T4CTTIrxd.java:787)
at oracle.jdbc.driver.T4CTTIrxd.unmarshal(T4CTTIrxd.java:704)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:526)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:179)
at oracle.jdbc.driver.T4CCallableStatement.execute_for_rows(T4CCallableStatement.java:782)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1027)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2887)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:2978)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4102)
at getConnection.TestProcedure.main(TestProcedure.java:37)
java.sql.SQLException: 违反协议
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
at oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:884)
at oracle.jdbc.driver.T4C7Ocommoncall.receive(T4C7Ocommoncall.java:132)
at oracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:384)
at oracle.jdbc.driver.PhysicalConnection.close(PhysicalConnection.java:1035)
at getConnection.TestProcedure.closeConn(TestProcedure.java:70)
at getConnection.TestProcedure.main(TestProcedure.java:47)


这种现象很可能是驱动版本太低导致(首先保证你的存储过程无问题,java书写方式正确),
后来改成版本更改的java ORCLE驱动 问题立即解决(换成ora9.2.0.3-jdk1.4.jar)
主要原因是classes12.jar 驱动的BUG所致,版本不支持,不支持oralce10g的某些特性,需要及时更新最新的oracle驱动 jar包,这只是一种很有可能存在的问题一个方面。
oracle中jdbc驱动包的说明
[url]http://junsansi.itpub.net/post/29894/279694[/url]
学习Oracle数据库的常用网址
[url]http://www.weste.net/html/200408/20040824QBI095416.html[/url]
oracle官网技术资料
[url]http://www.oracle.com/technology/global/cn/index.html[/url]
附件中有一个连接示例及各相关驱动包 :wink: