jdbc connection

Reply

Join Date: Aug 2008
Posts: 40
Reputation: coolbuddy059 has a little shameless behaviour in the past 
Solved Threads: 0
coolbuddy059 coolbuddy059 is offline Offline
Light Poster

jdbc connection

 
0
  #1
Apr 7th, 2009
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:thin127.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.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,444
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 510
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: jdbc connection

 
0
  #2
Apr 7th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC