Java – can oci driver for 11g (odbc5.jar) work with 10g client

javajdbcoracle10goracle11g

I need to connect to Oracle9,10 and 11 in my java application.The client will always be present where the app will be run and I want the app to just work with username,password and instance (specified in tnsnames.ora).Hence I would like oci drivers with a connection string of type : jdbc:oracle:oci:@testora .Im using the driver: oracle.jdbc.driver.OracleDriver.
I have a 10g client and am using jdk1.5. When I use the ojdbc14 jar from client lib path the app runs.

But if I use the ojdbc5 driver then the app fails with
Exception in thread "main" java.lang.UnsatisfiedLinkError: no ocijdbc11 in java.
library.path
exception.

What im looking for is a way to package a single jar(ojdbc5/ojdbc14) and a single driver which will use oci drivers to connect to the client that is present on local machine(9/10/11).This is the way I would prefer it.

If this is not possible can I search the unix box for oracle version,pick up the correct jar and then use it in classpath when invoking the app which is in jar format?

Thanks,
Fell

Best Answer

java.lang.UnsatisfiedLinkError: no ocijdbc11 in java.library.path

This means that you are missing a DLL (ocijdbc11.dll) in the Java library path. Make sure you have that DLL and start your program like this:

java -Djava.library.path=C:\mydirwiththedll com.mypackage.MyProgram