views:

1649

answers:

5

Hi,

I am running a series of JUnits using Apache ANT using JDK 1.5.

All JUnits that use an Oracle JDBC driver give the UnsatisfiedLinkError shown below.

What native library is it looking for and how do I solve this? What should the PATH variable contain?

oracle/jdbc/driver/T2CConnection.t2cGetCharSet([CI[CI[CI[CII[SLoracle/jdbc/driver/GetCharSetError;)S

java.lang.UnsatisfiedLinkError: oracle/jdbc/driver/T2CConnection.t2cGetCharSet([CI[CI[CI[CII[SLoracle/jdbc/driver/GetCharSetError;)S at oracle.jdbc.driver.T2CConnection.getCharSetIds(T2CConnection.java:2957) at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:320) at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:361) at oracle.jdbc.driver.T2CConnection.(T2CConnection.java:142) at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:79) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:595) at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:196) at oracle.jdbc.pool.OracleConnectionPoolDataSource.getPhysicalConnection(OracleConnectionPoolDataSource.java:114) at oracle.jdbc.pool.OracleConnectionPoolDataSource.getPooledConnection(OracleConnectionPoolDataSource.java:77) at oracle.jdbc.pool.OracleConnectionPoolDataSource.getPooledConnection(OracleConnectionPoolDataSource.java:59) at oracle.jdbc.pool.OracleConnectionCacheImpl.getNewPoolOrXAConnection(OracleConnectionCacheImpl.java:401) at oracle.jdbc.pool.OracleConnectionCacheImpl.setMinLimit(OracleConnectionCacheImpl.java:752)

A: 

Had this one, you should add classes12.jar or classes13.jar to your classpath (not sure about the name, it's been over a year, google these...)

Shachar
A: 

classes12.jar is in the classpath.

But it still doesn't work.

The old classes12 driver also comes with a second JAR containing lots of charset data, something with "NLS" in the name. Make sure that's in your classpath also. I recommend replacing the obsolete classes12 driver Oracle's latest driver, called ojdbc14.jar
skaffman
Depends on Oracle version - if the OP is using Oracle 8 he'll want to stick with classes12
cagcowboy
Why? The newer drivers work fine with the older servers, don't they? Unless he's stuck on JDK 1.3, in which case the ojdbc14 driver won't work.
skaffman
A: 

You need to pass -Djava.library.path=YOUR_ORACLE_HOME\bin to the JRE as a runtime parameter

So....

java [other java switches + runtime parameters] -Djava.library.path=YOUR_ORACLE_HOME\bin run-classname

Also, make sure the jar in the classpath is the same one as is in $ORACLE_HOME/jdbc/lib... overwrite the Eclipse one with the Oracle one if necessary.

If this doesn't work it would help to know which version of Oracle you're running since this will affect whether you should be using classes12.jar or ojdbc14.jar

cagcowboy
A: 

"Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native. "

Means that it is looking for a DLL/so -- you probably are using THICK driver ? JDBC 2 driver ?

If yes, then you might want to add OCI.DLL, etc.

anjanb
You tell the JRE where to find the DLL with -Djava.library.path
cagcowboy
+2  A: 

Resolved!

It was actually an out-of-date ojdbc14.jar file causing this issue. All I did was update it and the problem is fixed now. The classes file

Thanks