jabclab jabclab - 1 year ago 96
Java Question

java.lang.ArithmeticException when attempting to get connection in Oracle (64 bit)

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.

My Java is packaged up into a jar file and then deployed into Oracle using the

command line utility. A
is then created in the database which maps each method in a designated Java class to a PL/SQL function via call specifications.

Some of the columns which I'm working with are
s. In the Java I attempt to extract the value of this
(mapped in call specification as
) into a

private static String getStringFromCLOB(CLOB clob) throws SQLException {
long length = clob.length();
return clob.getSubString(1, (int) length);

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)

Before I was just seeing the message of the
so I wrapped the offending method's contents with a
try / catch
so I could dump the full stack trace to the

It is worth noting that I have had this working on Oracle (32bit) but it is not working on Oracle (64bit).

I have also had other Java-backed PL/SQL
s working without a problem. It is only the ones that attempt to make a connection that fail.

I have had a look in
and the jars, although named the same, seem to be different in these two distributions. The jars in the directory are ( size and 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) <-- probably the same

The manifest files of these jars confirm they are built for the specific version, i.e. or Is it possible a bug has been introduced in Or is it more likely to be user, i.e. my, error :-)

Also, where does the
class live?

Any help / guidance very much appreciated. Please let me know if you need more information.

Answer Source

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.

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().