Java.lang.ArithmeticException when trying to get connection in Oracle 11.2.0.2.0 (64 bit)

I am currently working with Java Stored Procedures in Oracle and I see strange behavior when trying to get a connection in my Java code.

My Java is packaged in a jar file and then deployed to Oracle using the loadjava command-line loadjava . Then, A package is created in the database, which maps each method in a particular Java class to the PL / SQL function using call specifications.

Some of the columns I'm working with are CLOB s. In Java, I'm trying to extract the value of this CLOB (displayed in the call spec as oracle.sql.CLOB ) in String :

 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 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 just saw the Exception message, I wrapped the contents of the abusive method with try / catch so that I could dump the full stack trace to System.out .

It is worth noting that I worked on Oracle 11.2.0.1.0 (32 bits), but it does not work on Oracle 11.2.0.2.0 (64bit) .

I also had work with PL / SQL function with Java support without any problems. Only those who try to make a connection do not work.

I looked at <ORACLE_HOME>\jdbc\lib , and the banks, although they called the same thing, seem to be different in the two distributions. Banks in the directory: (size 11.2.0.1.0 and size 11.2.0.2.0):

  • 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,062 KB | 2,102 KB)
  • 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 cans confirm that they are created for a specific version, that is, 11.2.0.1.0 or 11.2.0.2.0. Is it possible that the error was introduced in 11.2.0.2.0? Or, most likely, this is a user, that is mine, an error :-)

Also, where does the oracle.jdbc.driver.T2SConnection class live?

Any help / guidance is greatly appreciated. Please let me know if you need more information.

+7
source share
4 answers

For those who may run into this problem, we find that it was caused by a corrupt JVM installation in Oracle. This was probably due to a poor installation.

oracle.jdbc.driver.OracleConnection.defaultConnection() Oracle JVM aspect allowed oracle.jdbc.driver.OracleConnection.defaultConnection() to run without any problems, explicitly or called as part of the stack of another call, for example. oracle.sql.CLOB.length() .

0
source

I had this problem when my password expired. I decided it was just a password change.

+4
source

A similar problem with recent Oracle JDBC drivers. Our case seems to be the problem of mixing jars from different versions, such as 11.2.0.1 and 11.2.0.3, for example ojdbc6.jar from 11.2.0.1 and oi18n.jar from 11.2.0.3. One good method is to decompile all cans of the Oracle JDBC driver and view the line in the source code that causes the error. May provide an error / error hint.

Try using the same version of the JDBC driver on both client machines.

oracle.jdbc.driver.T2CConnection lives in any main driver bank, for example ojdbc5.jar.

+2
source

My Java / JDBC code suddenly stopped working from one day to another.

Same problem. Expired Password I tried both ojdbc6 and ojdbc7. Upgraded my VM environment. The code worked perfectly with a different database.

 target_user="c##ora$rman_bkp" Placeholder START_DATE=20170422 Placeholder START_DATE_TIME=2017Apr22-20h47m13s jdbcURL='jdbc:oracle:oci8:@twelve_static' Exception in thread "main" java.lang.ArithmeticException: / by zero at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:1387) at oracle.jdbc.driver.T2CPreparedStatement.<init>(T2CPreparedStatement.java:109) at oracle.jdbc.driver.T2CDriverExtension.allocatePreparedStatement(T2CDriverExtension.java:81) at oracle.jdbc.driver.PhysicalConnection.prepareStatementInternal(PhysicalConnection.java:2013) at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:1960) at oracle.jdbc.driver.T2CConnection.prepareStatement(T2CConnection.java:57) at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:1866) at oracle.jdbc.driver.T2CConnection.prepareStatement(T2CConnection.java:57) at LV.verifyLicensedDbId(LV.java:238) at RmanJ.<init>(RmanJ.java:1891) at RmanJ.main(RmanJ.java:1809) SYS@TWELVE :SQL> select account_status from dba_users where username='c##ora$rman_bkp'; ACCOUNT_STATUS -------------------------------- EXPIRED(GRACE) SYS@TWELVE :SQL> connect "c##ora$rman_bkp" Enter password: ERROR: ORA-28002: the password will expire within 5 days Connected. c## ora$rman_bkp@TWELVE :SQL> password Changing password for "c##ora$rman_bkp" Old password: New password: Retype new password: Password changed 

Tested my code and it worked fine again. Another unbelievable bug in Oracle software. Their quality assurance will never work out right. I am absolutely sure that they do not even have proper test plans, otherwise they will catch such serious errors as dividing by zero for the expired password.

+1
source

All Articles