Click here to Skip to main content
Rate this: bad
good
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";
			
		try
		{
			//REGISTER DRIVER
			Class.forName("oracle.jdbc.driver.OracleDriver");
			System.out.println("Driver registered successfully..");
			System.out.println();
			//ESTABLISH CONNECTION
			con = DriverManager.getConnection(url, uname, pwd);
			System.out.println("Connection established successfully..");
			System.out.println();	
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
		return con;
	}	
	public void closeAll()
	{
		try
		{
			con.close();
		}
		catch (SQLException e)
		{
			e.printStackTrace();
		}
		
	}
}
 

 
while running the login pagae ,in console it is saying
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
and
 
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
good
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; http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html[^]
 
/Fredrik
  Permalink  
v2
Comments
vinod.sambangi at 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 at 5-Feb-13 7:07am
   
I've added a link.
vinod.sambangi at 5-Feb-13 8:22am
   
Thank you
Fredrik Bornander at 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
0 OriginalGriff 200
1 PIEBALDconsult 150
2 BillWoodruff 148
3 Jochen Arndt 135
4 DamithSL 130
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2014
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