Error Unable To Load Java Class Oracle.jdbc.driver.oracledriver
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Cannot find or load oracle.jdbc.driver.OracleDriver up vote 1 down vote favorite I have installed Oracle 11.2 and Java: java version "1.7.0_09" Java(TM) SE Runtime Environment (build 1.7.0_09-b05) Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode) In the command line, if i try to: java oracle.jdbc.driver.OracleDriver Java says: impossibile to load or find oracle.jdbc.driver.OracleDriver I have copied ojdbc5.jar, ojdbc6.jar and ojdbc6_g.jar From oraclexe\app\oracle\product\11.2.0\server\jdbc\lib to C:\Program Files\Java\jdk1.7.0_09\lib If i run echo %CLASSPATH% I get: C:\Program Files\Java\jdk1.7.0_09\lib (ie where I have copied the jar files) Any reasons why Java can't find oracle.jdbc.driver.OracleDriver ? java oracle jdbc share|improve this question asked Jul 17 '13 at 13:50 anon add a comment| 4 Answers 4 active oldest votes up vote 3 down vote accepted You reference a folder on the classpath and expect it to load all jars in it. That is not how the classpath works, you need to reference specific jars (and normally you should NOT put third party jars inside the JDK folder). It is also important to know that the CLASSPATH is usually ignored by java applications, except for the most basic use cases. You can do what you try to achieve by doing: java -cp
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads http://stackoverflow.com/questions/17701610/cannot-find-or-load-oracle-jdbc-driver-oracledriver with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign http://stackoverflow.com/questions/15598757/oracle-jdbc-driver-oracledriver-classnotfoundexception up oracle.jdbc.driver.OracleDriver ClassNotFoundException up vote 3 down vote favorite 2 This is my code for which I am getting error. My classes12.jar has been imported as an external jar. import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class LoginAction extends HttpServlet { Connection conn; Statement stmt; ResultSet rs; String query = "SELECT * FROM v_urja_login"; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println("Hello"); String u_name = request.getParameter("uname"); String u_pass = request.getParameter("upass"); out.println(u_name); out.println(u_pass); try{ Class.forName("oracle.jdbc.driver.OracleDriver"); conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","urja","urja"); stmt = conn.createStatement(); rs = stmt.executeQuery(query); }catch(SQLException sex){ sex.printStackTrace(); } catch (ClassNotFoundException cnf) { cnf.printStackTrace(); } } } Stacktrace: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLo
- cause and solution java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver Exception comes when you try to connect Oracle database from Java program http://javarevisited.blogspot.com/2012/12/classnotfoundexception-oracle-jdbc-driver-oracledriver.html and Oracle driver is not available in Classpath. We have already seen How to connect Oracle database from Java program and found that, In order to connect to Oracle database, we load and register driver using Class.forName("oracle.jdbc.driver.OracleDriver") and this code loads a class at runtime using Reflection which error unable throws ClassNotFoundException if the class in question e.g. "oracle.jdbc.driver.OracleDriver" is not found. I have already listed down various reason of ClassNotFoundExcepiton in Java, which is also applicable in this case. By the way java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver is similar to java.lang.ClassNotFoundException: MySQL.jdbc.driver.MySQLDriver which comes if you try to connect MySQL database error unable to from Java program and corresponding driver is not in your classpath. You can refer link for getting more ideas which can be used to fix java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver error as well. How to solve java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver In order to solve java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver, we need these class either in the form of JAR or classes in your application classpath. For Oracle 10g and 11g, these are present in ojdbc6.jar or ojdbc6_g.jar, which are same except later is compiled with javac -g option to include debug information and tracing code. If you don't have this JAR then you can download it from http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html. Just download this JAR file and add into your Classpath by following steps given in How to set Classpath in Java. If you are not very comfortable with setting classpath then you can also put this JAR file in JRE/ext directory C:\Program Files\Java\jdk1.6.0_