Error connecting to oracle. Getting an UnsatisfiedLinkError for the method t2cGetCharSet

和自甴很熟 提交于 2019-12-11 00:55:39

问题


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?

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.<init>(PhysicalConnection.java:361)
        at oracle.jdbc.driver.T2CConnection.<init>(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) 

回答1:


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




回答2:


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




回答3:


"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.




回答4:


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




回答5:


Had the same problem; resolved by changing the connection url from jdbc:oracle:oci:@//localhost:1521/service_name to jdbc:oracle:thin:@//localhost:1521/service_name



来源:https://stackoverflow.com/questions/175055/error-connecting-to-oracle-getting-an-unsatisfiedlinkerror-for-the-method-t2cge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!