This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Oracle/OAS and the fly likes Jdk1.5 & Oracle 11g Database Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Jdk1.5 & Oracle 11g Database Connection" Watch "Jdk1.5 & Oracle 11g Database Connection" New topic
Author

Jdk1.5 & Oracle 11g Database Connection

Abilash Vs
Greenhorn

Joined: Mar 12, 2012
Posts: 5
Hi,

Recently we migrated to a environment with [Linux Servers (Virtual machine set up),JDK1.5 & Oracle 11g ].I have an application which establishes a thin client connection from Java (like as below) to Oracle 11g database.

----------------
OracleDataSource ods = new OracleDataSource();
ods.setURL("URL");
ods.setUser("UserName");
ods.setPassword("Password");
Connection conn = ods.getConnection();-----Failure point
---------------

However I face runtime issues intermitently exactly at the point "ods.getConnection() " and code doesn't enter my exception block.However this happens very intermittently and not always too ... .The same application was running fine in the previous environment [Unix servers,JDK1.5 & Oracle 10g]

There are two jars present in my lib (ojdbc14.jar and classes12dms.jar).

1) I am not sure whether there is a conflict in picking up these jars ...? Is there any relation between JDK version(JDK1.5) AND JDBC Driver Version(ojdbc14.jar) AND classes12.jar ?

2)Is it a mandate that ojdbc5 version of jar to be used with Jdk1.5 -Oracle 11g?



Regards,
Abilash
Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

Unless you're using Oracle Dynamic Monitoring Service (DMS), you don't need classes12dms.jar. Normally all you need is ojdbc14.jar, which is compiled for jdk 1.4 and 1.5. classes12.jar is for JDK 1.2 and 1.3 so you don't need that. ojdbc5.jar is also for JDK 1.5 and for Oracle 11g, although ojdbc14.jar should work, too. Check the following links for more info:
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-10201-088211.html

Edit: since this is a sporadic issue... I'm thinking maybe the DB is simply refusing or rejecting connections. Not sure why no Exception of some sort is thrown, but can you find out anything from the Oracle logs? Normally ojdbc14_g.jar can be used to provide more details in the stacktrace, assuming an Exception occurs within the driver.
Abilash Vs
Greenhorn

Joined: Mar 12, 2012
Posts: 5
Hi Keon,

Thanks for the quick response.We are not using ODMS services in our project and also don't see anything weird in DB logs.

1) The standalone java jar I am using is kept under lib directory which is basically the library directory of a web application and it has so many other libray jars and few custom java jars.There is ojdbc14.jar as well as classses12.jar under lib directory. Will this cause any problem if at all ?

2)Also my old environment set up is UNIX-Oracle10g-32bit Java and new environment is Linux-Oracle11g-64bit Java.Could there be a possibility of an issue at this level ? Are there any 64bit ojdbc driver jars that need to be used ? Reason being things worked fine in old environment and once moving on to the new environment,I have started observing this weird issue.Sometimes it works and few times it doesn't

3)I am able to see exception trace for only one particular java stand alone application,however for the others I am not able to see any logs.Most of the time that application works and if at all it fails,I see the
the below message followed by trace which exactly ends at the line

java.lang.NoClassDefFoundError: oracle/dms/instrument/ExecutionContextForJDBC

We however don't have any such class by name 'ExecutionContextForJDBC

Code failes at the below mentioned line in the trace:

Connection conn = ods.getConnection()

Any help on this is much appreciated.

Regards,
Abilash
Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

Abilash Vs wrote:There is ojdbc14.jar as well as classses12.jar under lib directory. Will this cause any problem if at all ?

Quite possibly. You're mixing different driver versions for the same DB. Get rid of classes12.jar, that's the old old driver for JDK 1.2 and 1.3. ojdbc14.jar is a newer driver for JDK 1.4 and 1.5.

Abilash Vs wrote:java.lang.NoClassDefFoundError: oracle/dms/instrument/ExecutionContextForJDBC

Instead of ojdbc14.jar, you might want to try ojdbc14dms.jar or ojdbc15dms.jar instead.

I think in the end the only thing you need is either ojdbc14dms.jar or ojdbc15dms.jar. Nothing else.
Abilash Vs
Greenhorn

Joined: Mar 12, 2012
Posts: 5
Hi Keon,

Thanks once again for the prompt reply.I will try the option of removing classes12.jar . I have tried options of using ojdbc14dms.jar in the past,but did not find any success.I can try the same again.

Also I have a couple of questions regarind the error ,

1)When I try to view the contents of ojdbc14dms.jar ,I do not find the package (oracle/dms/instrument) nor the class (ExecutionContextForJDBC) in it ?

2) I also have classes12dms.jar present under the library along with classes12.jar.There is a jar by name dms.jar itself (no clue where this is distributed,but as per my reading it looks like it is supplied along with Oracle application server).But none of these jars have the package 'oracle/dms/instrument' at all .I am wondering how this is not coming up in my old environment(Oracle 10g with 32-bit java compiler)

Pasting the complete Exception Trace: This error does not come up always,it is intermittent and the failure rate is sometimes 1 out of 10 or even 1 out of 5 at times
--------------------------------------------

java.lang.NoClassDefFoundError: oracle/dms/instrument/ExecutionContextForJDBC
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:340)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:164)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:34)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:767)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)

Once again ,your help on this is very much appreciated.


Many thanks,
Abilash

Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

Remove all jar files related to Oracle DB from your app lib folder. Also make sure your classpath doesn't include any other DB jars from anywhere else (i.e. app server).

Then try again with just ojdbc5.jar. If that doesn't work, try with just ojdbc5dms.jar. If that doesn't work, do a search for file "dms.jar" somewhere under the Oracle jdbc directory. Then copy that file to include in your classpath. Use that file in addition to one of ojdbc5dms.jar or ojdbc5.ja (try which one).
Abilash Vs
Greenhorn

Joined: Mar 12, 2012
Posts: 5
Hi Koen,,

Thanks a lot.I removed both the jars (classes12.jar & classes12dms.jar) from my library and just retained ojdbc14.jar.

I automated lot of tests and now things to seem work fine ,I havent seen the intermittent DB connection failures for the past two days.

Many thanks for your thoughts and suggestions..

Regards,
Abilash
 
 
subject: Jdk1.5 & Oracle 11g Database Connection