• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting class not found exception

 
Vibhas Kumar
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 {

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\

Can anyone suggest me what to do.

 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vibhas Kumar
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oracle.jdbc.driver.OracleDriver

not "oracle.jdbc.OracleDriver"
 
Vibhas Kumar
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
AdminConsole.jpg
[Thumbnail for AdminConsole.jpg]
AdminConsole
 
Vijitha Kumara
Bartender
Posts: 3914
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are trying to run a standalone class against the DB, right? So how do you run the class (i.e: command)?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic