wood burning stoves 2.0*
The moose likes JDBC and the fly likes getting class not found exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "getting class not found exception" Watch "getting class not found exception" New topic

getting class not found exception

Vibhas Kumar

Joined: Oct 13, 2009
Posts: 28
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;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Driver {
public static void main(String args[]) throws ClassNotFoundException,
SQLException {

// or you can use:
// DriverManager.registerDriver(
// new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection(
"jdbcracle:thin:@", "scott", "tiger");

Statement stmt = conn.createStatement();
ResultSet rset = stmt
.executeQuery("select * from customer");
while (rset.next())


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\

Can anyone suggest me what to do.

Jan Cumps

Joined: Dec 20, 2006
Posts: 2491

Vibhas Kumar wrote:
my class path is showing following thing
Variable value: oracle.jdbc.OracleDriver
Your classpath should contain location and name of the Oracle jdbc library (e.g.: c:\mylibs\oracle\odbc14.jar)

OCUP UML fundamental and ITIL foundation
youtube channel
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60766

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.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vibhas Kumar

Joined: Oct 13, 2009
Posts: 28
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

Joined: Jul 26, 2010
Posts: 2
Can you post your class path? And the process you go through to change, you might have it pointed to the wrong directory.

john chris

Joined: Aug 02, 2010
Posts: 8

not "oracle.jdbc.OracleDriver"
Vibhas Kumar

Joined: Oct 13, 2009
Posts: 28
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 .

[Thumbnail for AdminConsole.jpg]

Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3816

You are trying to run a standalone class against the DB, right? So how do you run the class (i.e: command)?

[How to ask questions] [Twitter]
subject: getting class not found exception
Similar Threads
At Wits End.....
cannot resolve symbol - help
install jdk vista problem
Installing java and putting it in the Path variable.
java onn windows vista