This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi friends i am facing the following error while trying to connect to a database through java code:
Exception in thread "Main Thread" java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.example.model.Driver.main(Driver.java:13)
My java code is:
package com.example.model;
Class.forName("oracle.jdbc.OracleDriver");
// or you can use:
// DriverManager.registerDriver(
// new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection(
"jdbcracle:thin:@127.0.0.1:1521:ORCL", "scott", "tiger");
Statement stmt = conn.createStatement();
ResultSet rset = stmt
.executeQuery("select * from customer");
while (rset.next())
System.out.println(rset.getString(1));
rset.close();
stmt.close();
conn.close();
}
}
As per i came to know it could be due to class path issue but don't know how to resolve
my class path is showing following thing
Variable value: oracle.jdbc.OracleDriver
and path is showing :
C:\app\admin\product\11.2.0\dbhome_1\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Common Files\Roxio Shared\10.0\DLLShared\;C:\Program Files\Common Files\Roxio Shared\DLLShared\
Please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.
Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.
Hi Jan i downloaded a classes12.jar file and put it into C:\bea\user_project\workspace\jdk160_05\jre\lib\ext folder and set the class path as well but still i am getting the same error.
Kindly suggest.
Ramon Gonzalez
Greenhorn
Joined: Jul 26, 2010
Posts: 2
posted
0
Can you post your class path? And the process you go through to change, you might have it pointed to the wrong directory.
RJ
john chris
Greenhorn
Joined: Aug 02, 2010
Posts: 8
posted
0
oracle.jdbc.driver.OracleDriver
not "oracle.jdbc.OracleDriver"
Vibhas Kumar
Greenhorn
Joined: Oct 13, 2009
Posts: 28
posted
0
Hi friends still i am unable to resolve this issue. I set my class path to C:\bea\user_project\workspace\wlserver_10.3\server\ext\jdbc\oracle\11g\ojdbc5.jar;
i am using weblogic 10.3 workspace and weblogic 10.3 server.
what mistake i could possibly would have made kindly suggest.I am also attaching my data source of web-logic admin console .