File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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(
at com.example.model.Driver.main(
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 (


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: 2565

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
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

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] [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: 3902

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]
I agree. Here's the link:
subject: getting class not found exception
It's not a secret anymore!