尝试在Oracle 11.2.0.2.0(64位)中建立连接时发生java.lang.ArithmeticException [英] java.lang.ArithmeticException when attempting to get connection in Oracle 11.2.0.2.0 (64 bit)
问题描述
我目前正在使用Oracle中的Java存储过程,并试图在Java代码中建立连接时看到一些奇怪的行为.
I'm currently working with Java Stored Procedures in Oracle and am seeing some strange behaviour when attempting to get a connection within my Java code.
将我的Java打包到jar文件中,然后使用loadjava
命令行实用程序将其部署到Oracle中.然后在数据库中创建package
,该数据库通过调用规范将指定Java类中的每个方法映射到PL/SQL函数.
My Java is packaged up into a jar file and then deployed into Oracle using the loadjava
command line utility. A package
is then created in the database which maps each method in a designated Java class to a PL/SQL function via call specifications.
我正在使用的某些列是CLOB
.在Java中,我尝试将此CLOB
的值(在呼叫规范中映射为oracle.sql.CLOB
)提取到String
中:
Some of the columns which I'm working with are CLOB
s. In the Java I attempt to extract the value of this CLOB
(mapped in call specification as oracle.sql.CLOB
) into a String
:
private static String getStringFromCLOB(CLOB clob) throws SQLException {
long length = clob.length();
return clob.getSubString(1, (int) length);
}
运行此代码时,我在SQL * Plus中得到以下堆栈跟踪:
When I run this code I get the following stack trace showing up in SQL*Plus:
java.lang.ArithmeticException: / by zero
at oracle.jdbc.driver.T2SConnection.<init>(T2SConnection.java:107)
at oracle.jdbc.driver.T2SDriverExtension.getConnection(T2SDriverExtension.java:31)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:481)
at oracle.jdbc.driver.OracleDriver.defaultConnection(OracleDriver.java:505)
at oracle.sql.DatumWithConnection.getPhysicalConnection(DatumWithConnection.java:53)
at oracle.sql.DatumWithConnection.getInternalConnection(DatumWithConnection.java:177)
at oracle.sql.CLOB.getDBAccess(CLOB.java:1383)
at oracle.sql.CLOB.length(CLOB.java:197)
在我刚刚看到Exception
的消息之前,我用try / catch
包裹了有问题的方法的内容,这样我就可以将完整的堆栈跟踪信息转储到System.out
.
Before I was just seeing the message of the Exception
so I wrapped the offending method's contents with a try / catch
so I could dump the full stack trace to the System.out
.
值得注意的是,我已经在Oracle 11.2.0.1.0(32位)上运行此功能,但是在Oracle 11.2.0.2.0(64位)上无法运行.
我也有其他支持Java的PL/SQL function
正常工作.只是那些尝试建立连接失败的人.
I have also had other Java-backed PL/SQL function
s working without a problem. It is only the ones that attempt to make a connection that fail.
我在<ORACLE_HOME>\jdbc\lib
中进行了查看,这些罐子虽然命名相同,但在这两个发行版中似乎有所不同.目录中的jar分别为(显示的大小为11.2.0.1.0和11.2.0.2.0):
I have had a look in <ORACLE_HOME>\jdbc\lib
and the jars, although named the same, seem to be different in these two distributions. The jars in the directory are (11.2.0.1.0 size and 11.2.0.2.0 size shown):
-
ojdbc5.jar
(1,950KB | 1,983KB) -
ojdbc5_g.jar
(3,010KB | 3,271KB) -
ojdbc5dms.jar
(2,374KB | 2,489KB) -
ojdbc5dms_g.jar
(3,030KB | 3,291KB) -
ojdbc6.jar
(2,062KB | 2,102KB) -
ojdbc6_g.jar
(3,323KB | 3,782KB) -
ojdbc6dms.jar
(2,594KB | 2,698KB) -
ojdbc6dms_g.jar
(3,344KB | 3,805KB) -
simplefan.jar
(20KB | 20KB)<-可能相同
ojdbc5.jar
(1,950KB | 1,983KB)ojdbc5_g.jar
(3,010KB | 3,271KB)ojdbc5dms.jar
(2,374KB | 2,489KB)ojdbc5dms_g.jar
(3,030KB | 3,291KB)ojdbc6.jar
(2,062KB | 2,102KB)ojdbc6_g.jar
(3,323KB | 3,782KB)ojdbc6dms.jar
(2,594KB | 2,698KB)ojdbc6dms_g.jar
(3,344KB | 3,805KB)simplefan.jar
(20KB | 20KB) <-- probably the same
这些jar的清单文件确认它们是针对特定版本(即11.2.0.1.0或11.2.0.2.0)构建的. 11.2.0.2.0中是否可能引入了错误?还是更有可能是用户,即我的错误:-)
The manifest files of these jars confirm they are built for the specific version, i.e. 11.2.0.1.0 or 11.2.0.2.0. Is it possible a bug has been introduced in 11.2.0.2.0? Or is it more likely to be user, i.e. my, error :-)
oracle.jdbc.driver.T2SConnection
类还住在哪里?
非常感谢任何帮助/指导.如果您需要更多信息,请告诉我.
Any help / guidance very much appreciated. Please let me know if you need more information.
推荐答案
对于那些可能遇到此问题的人,我们发现它是由Oracle中JVM安装损坏引起的.这可能是由于安装错误导致的.
To those that might come across this issue we discovered that it was caused by a corruption of the JVM install within Oracle. This probably occurred due to a bad installation.
重新安装Oracle的JVM方面使oracle.jdbc.driver.OracleConnection.defaultConnection()
可以运行而不会出现任何问题,无论是显式调用还是作为另一个调用的堆栈的一部分进行了调用,例如oracle.sql.CLOB.length()
.
Reinstalling the JVM aspect of Oracle allowed oracle.jdbc.driver.OracleConnection.defaultConnection()
to run without any issues whether explicitly called or called as part of the stack of another call, e.g. oracle.sql.CLOB.length()
.
这篇关于尝试在Oracle 11.2.0.2.0(64位)中建立连接时发生java.lang.ArithmeticException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!