DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   java runtime error for database connection (http://www.daniweb.com/forums/thread102611.html)

radhachowdary Dec 27th, 2007 4:19 pm
java runtime error for database connection
 
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:thin:@localhost: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.

masijade Dec 27th, 2007 5:15 pm
Re: java runtime error for database connection
 
You haven't included the jarfile containing the Oracle JDBC Driver on the classpath.

~s.o.s~ Dec 28th, 2007 11:39 pm
Re: java runtime error for database connection
 
>
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.

masijade Dec 29th, 2007 3:16 am
Re: java runtime error for database connection
 
Ha. ;-)

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

~s.o.s~ Dec 29th, 2007 3:35 am
Re: java runtime error for database connection
 
> These classpath questions have simply become knee-jerk reactions. ;-)
You can say that again. :-)


All times are GMT -4. The time now is 2:34 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC