java runtime error for database connection

Reply

Join Date: Dec 2007
Posts: 1
Reputation: radhachowdary is an unknown quantity at this point 
Solved Threads: 0
radhachowdary radhachowdary is offline Offline
Newbie Poster

java runtime error for database connection

 
0
  #1
Dec 27th, 2007
hi all
i was installed jdk1.5 and oracle 10g.
i got a runtime error like this.
i want to compile and run the same program in command prompt and eclipse also .

import java.sql.*;
public class Oapp2
{
public static void main(String args[])
{

try{


Class.forName("oracle:jdbc:driver:OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thinlocalhost:1521:xe","scott","tiger");
System.out.println("connected");
}
catch(Exception e)
{
e.printStackTrace();
}
}
}


i got an same error in editplus and eclipse as following.
java.lang.ClassNotFoundException: oracle:jdbc:driver:OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at Oapp2.main(Oapp2.java:11)

plese help me.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,336
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 250
Moderator
masijade's Avatar
masijade masijade is online now Online
Nearly a Posting Maven

Re: java runtime error for database connection

 
0
  #2
Dec 27th, 2007
You haven't included the jarfile containing the Oracle JDBC Driver on the classpath.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,600
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 462
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: java runtime error for database connection

 
0
  #3
Dec 28th, 2007
> Class.forName("oracle:jdbc:driver:OracleDriver"); There is no class which goes by the name of oracle:jdbc:driver:OracleDriver . Replace those : with . and you should be fine provided you have included the classes12.jar or some other thin oracle driver in your classpath.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,336
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 250
Moderator
masijade's Avatar
masijade masijade is online now Online
Nearly a Posting Maven

Re: java runtime error for database connection

 
0
  #4
Dec 29th, 2007
Ha. ;-)

Din't really look at the class name. These classpath questions (at least because of other forums) have simply become knee-jerk reactions. ;-)
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,600
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 462
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: java runtime error for database connection

 
0
  #5
Dec 29th, 2007
> These classpath questions have simply become knee-jerk reactions. ;-)
You can say that again. :-)
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC