I have a Windows desktop Java application that was created in Eclipse using Java 1.5 JRE as the compiler and Oracle OCI drivers to communicate with multiple databases simultaneously. My system is running the Oracle 11g client. I'm a newbie still at Java and as such, I recently learned it's not best practice to install the necessary Oracle OCI drivers on the %JAVA_HOME%\lib\ext path. My program functioned correctly until the day I removed the ojdbc5.jar driver from the %JAVA_HOME%\lib\ext folder.
Now, in spite of adding the ojdbc5.jar to my Build Path in the project within Eclipse, my application errors with the following message:
Exception in thread "pool-1-thread-1" java.lang.UnsatisfiedLinkError: t2cCreateState at oracle.jdbc.driver.T2CConnection.t2cCreateState(Native Method) at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:338) at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:490) at oracle.jdbc.driver.T2CConnection.(T2CConnection.java:133) at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:53) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:465) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Sou开发者_开发知识库rce) at pkgPasswordChamp.Password_Champ.getConnection(Password_Champ.java:555) at pkgPasswordChamp.Password_Champ.executeStatement(Password_Champ.java:635) at pkgPasswordChamp.Password_Champ.loginToMarket(Password_Champ.java:678) at pkgPasswordChamp.Password_Champ.access$0(Password_Champ.java:663) at pkgPasswordChamp.Password_Champ$currentMarket.run(Password_Champ.java:753) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
To resolve the issue, so far, I've attempted to modify my Windows XP Path System variable and my Windows XP Classpath System variable. Each variable appears to contain the reference to the necessary folders and files.
Path: C:\WINDOWS\system32\WindowsPowerShell\v1.0;%ORACLE_HOME%\bin;%JAVA_HOME%\bin;%ORACLE_HOME%\bin\ocijdbc11.dll;
Classpath: .;C:\Program .;C:\Program Files\QuickTime\QTSystem\QTJava.zip;.;.;C:\PROGRA~1\JMF21~1.1E\lib\sound.jar;C:\PROGRA~1\JMF21~1.1E\lib\jmf.jar;C:\PROGRA~1\JMF21~1.1E\lib;%systemroot%\java\classes;%ORACLE_HOME%\jdbc\lib\ojdbc5.jar;.
Other forums have suggested that the java.lang.UnsatisfiedLinkError: t2cCreateState error implies a DLL associated with the Oracle driver is missing. I attempted to add the oci.dll and the ocijdbc11.dll files to the Build Path in Eclipse, but I still received the same error.
Can anyone explain why the "java.lang.UnsatisfiedLinkError: t2cCreateState" is being thrown and what steps I can take to resolve the error?
It's a mystery to me why the application works fine with only the ojdbc5.jar on the %JAVA_HOME%\lib\ext folder, but fails when the ojdbc5.jar is removed and placed on the Build Path of the application. Any help for this newbie would be greatly appreciated!
"Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native."
I'm not exactly sure why moving the Jar makes it work / not work, but is it something to do with Java no longer being able to find the Oracle Client installation and it's DLLs?
Try copying the DLLs it needs into the folder where you are running Java from, or maybe adding the Oracle Client install dir to the classpath?
(ps - if you are using more than one database, you could run into problems of not having a transaction manager to handle two phase commits - watch out you don't get inconsistent data between the databases!)
精彩评论