连接到 oracle 时出错。获取方法 t2cGetCharSet 的 UnsatisfiedLinkError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/175055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error connecting to oracle. Getting an UnsatisfiedLinkError for the method t2cGetCharSet
提问by
I am running a series of JUnits using Apache ANT using JDK 1.5.
我正在使用 Apache ANT 和 JDK 1.5 运行一系列 JUnit。
All JUnits that use an Oracle JDBC driver give the UnsatisfiedLinkError shown below.
所有使用 Oracle JDBC 驱动程序的 JUnit 都会给出如下所示的 UnsatisfiedLinkError。
What native library is it looking for and how do I solve this? What should the PATH variable contain?
它在寻找什么本地库,我该如何解决这个问题?PATH 变量应该包含什么?
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)
回答by
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
实际上是一个过时的 ojdbc14.jar 文件导致了这个问题。我所做的只是更新它,现在问题已解决。类文件
Thanks
谢谢
回答by Shachar
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...)
有了这个,你应该将 classes12.jar 或 classes13.jar 添加到你的类路径中(不确定名称,已经一年多了,谷歌这些......)
回答by cagcowboy
You need to pass -Djava.library.path=YOUR_ORACLE_HOME\bin to the JRE as a runtime parameter
您需要将 -Djava.library.path=YOUR_ORACLE_HOME\bin 作为运行时参数传递给 JRE
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.
另外,请确保类路径中的 jar 与 $ORACLE_HOME/jdbc/lib 中的 jar 相同...如有必要,用 Oracle 覆盖 Eclipse 之一。
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
如果这不起作用,了解您正在运行哪个版本的 Oracle 会有所帮助,因为这将影响您是否应该使用 classes12.jar 或 ojdbc14.jar
回答by anjanb
"Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native. "
“如果 Java 虚拟机找不到声明为本机的方法的适当本机语言定义,则抛出此问题。”
Means that it is looking for a DLL/so -- you probably are using THICK driver ? JDBC 2 driver ?
意味着它正在寻找一个 DLL/so——你可能正在使用 THICK 驱动程序?JDBC 2 驱动程序?
If yes, then you might want to add OCI.DLL, etc.
如果是,那么您可能想要添加 OCI.DLL 等。
回答by aamir
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
有同样的问题;通过将连接 url 从 jdbc:oracle:oci:@//localhost:1521/service_name 更改为 jdbc:oracle:thin:@//localhost:1521/service_name 来解决