Connecting Tech Pros Worldwide Forums | Help | Site Map

Excution problem

Newbie
 
Join Date: Aug 2007
Posts: 13
#1: Aug 31 '07
Hi!
Sir, First of all i want to thank this site for providing such good information.

coming to problem am facing problem in executing the below program and am gettng the error pasted at bottom after the program....
please help me in this case

if the problem is with setting the path please give me a detailed explanation of setting the path.


import java.sql.*;
import java.lang.*;


public class AviDemo
{
public static void main(String a[]) throws Exception
{
System.out.println("...............Hello.......... ");
try
{
Class.forName("jdbc.oracle.OracleDriver");
Connection con=DriverManager.getConnection("oralce:jdbc:thin: localhost@:1521:xe","system","123");

}catch(Exception e)
{
e.printStackTrace();
}
System.out.println("Connected");

}
}



...............Hello..........
java.lang.ClassNotFoundException: jdbc.oracle.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at AviDemo.main(AviDemo.java:12)
Connected
kreagan's Avatar
Familiar Sight
 
Join Date: Aug 2007
Location: New Hampshire
Posts: 153
#2: Aug 31 '07

re: Excution problem


Quote:

Originally Posted by mailavi

Hi!
Sir, First of all i want to thank this site for providing such good information.

coming to problem am facing problem in executing the below program and am gettng the error pasted at bottom after the program....
please help me in this case

if the problem is with setting the path please give me a detailed explanation of setting the path.


import java.sql.*;
import java.lang.*;


public class AviDemo
{
public static void main(String a[]) throws Exception
{
System.out.println("...............Hello.......... ");
try
{
Class.forName("jdbc.oracle.OracleDriver");
Connection con=DriverManager.getConnection("oralce:jdbc:thin: localhost@:1521:xe","system","123");

}catch(Exception e)
{
e.printStackTrace();
}
System.out.println("Connected");

}
}



...............Hello..........
java.lang.ClassNotFoundException: jdbc.oracle.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at AviDemo.main(AviDemo.java:12)
Connected

First you have to download the driver. Then you must locate the library file - most likely in the bin directory. The you must have your project recognize to look for that library. You can do this number of ways. When I used eclipse, the IDE had an option where you can select that file. If you don't use an IDE, read section five of the link below.

Path Info
Member
 
Join Date: Aug 2007
Posts: 36
#3: Sep 1 '07

re: Excution problem


i think the driver name is

oracle.jdbc.driver.OracleDriver


URL is

jdbc:oracle:thin:@localhost:1521
kreagan's Avatar
Familiar Sight
 
Join Date: Aug 2007
Location: New Hampshire
Posts: 153
#4: Sep 2 '07

re: Excution problem


Quote:

Originally Posted by shaileshkumar

i think the driver name is

oracle.jdbc.driver.OracleDriver


URL is

jdbc:oracle:thin:@localhost:1521

Yup, that's the driver. The URL is the socket to connect to the database. The errors above are not due to the URL. You need to set the path to read the OracleDriver.

Good luck. Doing it the first time can be tricky.
Setting a Path

The class path should be where that driver is.

In your code, you might need to put an include jdbc.oracle.OracleDriver ... or else jdbc.*

Good luck
Reply


Similar Java bytes