Click here to Skip to main content
11,932,402 members (54,293 online)
Rate this:
Please Sign up or sign in to vote.
See more: Java Eclipse
I am trying to connect to database in eclipse to execute a simple login application in which if suppose if login credentials are correct then it will redirect to some other page or else it will tell as incorrect details.

public class DBConnection {
	static Connection con = null;
	public DBConnection()
	public static Connection getConnection() throws SQLException
	///public static void main(String[] args) throws ClassNotFoundException, SQLException
		String url = "jdbc:oracle:thin:@localhost:1521:XE";
		String uname = "system";
		String pwd = "password";
			System.out.println("Driver registered successfully..");
			con = DriverManager.getConnection(url, uname, pwd);
			System.out.println("Connection established successfully..");
		catch(Exception e)
		return con;
	public void closeAll()
		catch (SQLException e)

while running the login pagae ,in console it is saying
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

in that

java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)

Please tell me the solution
Posted 5-Feb-13 0:21am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to add the jar containing oracle.jdbc.driver.OracleDriver to the classpath.

If you can't find that on your hard drive you should be able to get it from here;[^]

vinod.sambangi 5-Feb-13 6:51am
Can you please tell me ,what is the name of the jar file and where i can add that jar file.Please tell me .
Fredrik Bornander 5-Feb-13 7:07am
I've added a link.
vinod.sambangi 5-Feb-13 8:22am
Thank you
Fredrik Bornander 5-Feb-13 8:44am
You should mark the answer as Accepted if it solved your problem so that we can close the question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100