"java.lang.unsatisfiedlinkerror no ocijdbc11 in java.library.path" error comes when you try to connect to Oracle 11g database using OCI (thick) driver by using tns name, but ocijdbc11.dll file is not available in PATH or java.library.path environment variable. ocijdbc11.dll is a native library and if you know Java searches native library in PATH or a location specified by java.library.path system property, if it doesn't find the dll, then it throws java.lang.unsatisfiedlinkerror no ocijdbc11 in java.library.path error. This dll is usually find in C:\Programs\Oracle\ora11g\bin\ocijdbc11.dll, but it could vary depending upon your Oracle installation. First step to solve this error is search for this dll in your machine, if you are using windows, just search in your C drive. If the dll is not there then you need to download that from Oracle's website. If its already present then just add its location into PATH variable. If you are explicitly providing java.library.path then also provide it there e.g.
-Djava.library.path=C:\Programs\Oracle\ora11g\bin\ocijdbc11.dll . By the way, if you truly wants to learn Java database programming from scratch, I suggest you to take a look at Practical database programming with Java book by Ying Bai. This book explains every important detail of Java database connectivity.
By the way this is not the standard way to connect to Oracle database from Java. Oracle users mainly use OCI driver for OS authentication or if they don't know the IP address of server and want to connect using TNSE, but if you are not concerned of that, you can always use Oracle JDBC thin driver to connect. For that you just need to include ojdbc.jar in your classpath. Just remember if you use an OCI URL e.g. "jdbc:oracle:oci:/@"+tnsName then you are using thick driver and you need oracle client libraries on the PATH, for that you need Oracle client to be installed in your machine, but if you use thin driver with following URL format "jdbc:oracle:thin:@"+dbServer+":"+port+":"+SID; you just need driver's JAR file and no native library will be required because its type 4 pure Java driver.
Second solution is to use Oracle JDBC thin driver to connect Orace database. For this you need to change your JDBC URL format as "jdbc:oracle:thin:@"+dbServer+":"+port+":"+SID; and include ojdbc6.jar in to your CLASSPATH. Always remember difference between PATH and CLASSPATH, PATH is used to locate executable files, native library files but JAR is always loaded from classpath. This is also standard way to connect to Oracle 11g database.
If you are using Oracle 10g then you will likely to see java.lang.unsatisfiedlinkerror no ocijdbc10 in java.library.path, solution is same find the dll and add into PATH. Also ojdbc6.jar can be found in C:\Programs\Oracle\ora11g\jdbc\lib\ location, where ORACLE_HOME.
Since this is also a type of java.lang.unsatisfiedlinkerror, you can also see this tutorial to get a general idea about how to solve this error in Java. You will likely to see this type of error whenever your Java program will use native libraries, either internal or external to do stuff.
That's all about how to fix java.lang.unsatisfiedlinkerror no ocijdbc11 in java.library.path error in Java. You get this error when you try to connect to an Oracle 11g database from Java program by using its TNS name and not the IP address. You can fix this error by adding ocijdbc11.dll in your PATH environment variable or into your java.library.path variable. If that DLL is not available in your system then download and install Oracle client like SQL Developer, which contains both thick and thin JDBC driver to connect to Oracle database. If you get java.lang.unsatisfiedlinkerror no ocijdbc10 in java.library.path it means you are connecting to Oracle 10g database but solution is same with only difference in Oracle version difference. Let us know if you face any issue while connecting to Oracle database from Java and I will try to help you here.
Other common error which comes while connecting to database like Oracle, MySQL, SQL SERVER from Java program :
-Djava.library.path=C:\Programs\Oracle\ora11g\bin\ocijdbc11.dll . By the way, if you truly wants to learn Java database programming from scratch, I suggest you to take a look at Practical database programming with Java book by Ying Bai. This book explains every important detail of Java database connectivity.
By the way this is not the standard way to connect to Oracle database from Java. Oracle users mainly use OCI driver for OS authentication or if they don't know the IP address of server and want to connect using TNSE, but if you are not concerned of that, you can always use Oracle JDBC thin driver to connect. For that you just need to include ojdbc.jar in your classpath. Just remember if you use an OCI URL e.g. "jdbc:oracle:oci:/@"+tnsName then you are using thick driver and you need oracle client libraries on the PATH, for that you need Oracle client to be installed in your machine, but if you use thin driver with following URL format "jdbc:oracle:thin:@"+dbServer+":"+port+":"+SID; you just need driver's JAR file and no native library will be required because its type 4 pure Java driver.
Error :
Exception in thread "main" java.lang.UnsatisfiedLinkError: no ocijdbc11 in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source)
Analysis :
If you look at the error you will find that Java is complaining that ocijdbc11 dll is not found in java.library.path. If you further look then you will say that Oracle Driver is using System.loadLibrary() method to load native library, which explains why Java is searching for dll in java.library.path. BTW this is optional if you don't provide this system property Java will look on all folders included in PATH environment variable.Solution:
There are two ways to solve the problem, first check if ocijdbc11.dll is present in your machine or not. For that do a wide search on your C driver where programs are installed. If you don't find this dll file then you need to install Oracle client to get this dll. If you install Oracle 11g in 64-bit Windows 7 machine then this native library can be found in C:\Programs\Oracle\ora11g\bin\ocijdbc11.dll folder. Now just add this folder in to your PATH and run your program again, provided any other error you should be able to connect to Oracle server.Second solution is to use Oracle JDBC thin driver to connect Orace database. For this you need to change your JDBC URL format as "jdbc:oracle:thin:@"+dbServer+":"+port+":"+SID; and include ojdbc6.jar in to your CLASSPATH. Always remember difference between PATH and CLASSPATH, PATH is used to locate executable files, native library files but JAR is always loaded from classpath. This is also standard way to connect to Oracle 11g database.
java.lang.unsatisfiedlinkerror no ocijdbc11 in java.library.path in SQL Developer
After Toad, Oracle's SQL Developer is the next popular tool for connecting to Oracle database and this a Java client. That's why you need both thick and thin driver in your machine, which I guess also comes when you install SQL Developer. It uses thick driver when using TNS name and thin driver when using basic connection. For thick driver you need ocijdbc11.dll in your PATH and for thin driver you need ojdbc6.jar or ojdbc6_g.jar, later one is debug version. So if you get this error while using SQL Developer, follow the above step to sort it out.If you are using Oracle 10g then you will likely to see java.lang.unsatisfiedlinkerror no ocijdbc10 in java.library.path, solution is same find the dll and add into PATH. Also ojdbc6.jar can be found in C:\Programs\Oracle\ora11g\jdbc\lib\ location, where ORACLE_HOME.
Since this is also a type of java.lang.unsatisfiedlinkerror, you can also see this tutorial to get a general idea about how to solve this error in Java. You will likely to see this type of error whenever your Java program will use native libraries, either internal or external to do stuff.
That's all about how to fix java.lang.unsatisfiedlinkerror no ocijdbc11 in java.library.path error in Java. You get this error when you try to connect to an Oracle 11g database from Java program by using its TNS name and not the IP address. You can fix this error by adding ocijdbc11.dll in your PATH environment variable or into your java.library.path variable. If that DLL is not available in your system then download and install Oracle client like SQL Developer, which contains both thick and thin JDBC driver to connect to Oracle database. If you get java.lang.unsatisfiedlinkerror no ocijdbc10 in java.library.path it means you are connecting to Oracle 10g database but solution is same with only difference in Oracle version difference. Let us know if you face any issue while connecting to Oracle database from Java and I will try to help you here.
Other common error which comes while connecting to database like Oracle, MySQL, SQL SERVER from Java program :
- How to connect to MySQL database from Java Program [steps]
- General Guide to solve java.lang.ClassNotFoundException in Java [guide]
- java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory? [solution]
- How to solve java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver in Java? [solution]
- How to fix java.lang.ClassNotFoundException: org.postgresql.Driver error in Java? [solution]
- How to solve java.lang.ClassNotFoundException:org.Springframework.Web.Context.ContextLoaderListener [solution]
- How to solve java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in Java MySQL? [solution]