954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

jdbc connection

I've tried to make connection with oracle database using code:


import java.io.*;
import java.sql.*;

public class dbcon{
public static void main(String[] args) {
try{
String driver="oracle.jdbc.driver.OracleDriver";
Class.forName(driver);

String jdbcURL="jdbc:oracle:thin:@127.0.0.1:1521:stud";
String username="scott";
String password="tiger";
Connection conn=DriverManager.getConnection(jdbcURL,username,password);
System.out.println("***Connected to the database***");

conn.close();
}catch(ClassNotFoundException e){
System.out.println("could not find the database driver");
}catch(SQLException e){
System.out.println("The sql state=%s"+e.getSQLState());
}
}
}


But I'm getting ClassNotFoundExeption.Please resolve this.

coolbuddy059
Light Poster
45 posts since Aug 2008
Reputation Points: 1
Solved Threads: 0
 

By 29 posts, you should understand how to use [code] [/code] tags.

As for the exception, make sure you have that jar file in your class path.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You