Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / February 2006

Tip: Looking for answers? Try searching our database.

Oracle Thin JDBC Driver Problem - Run time

Thread view: 
saro_77_vlr - 16 Feb 2006 10:45 GMT
Hi,
i did the following code:

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

class TestCommand {

public static void main(String a[] ) throws SQLException
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
 Connection con =

DriverManager.getConnection("jdbc:oracle:thin:@project:1521:proj","project1",
"admission");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("select *  from admin");
    while( rs.next() )
    System.out.println( rs.getString("regno")) ;
}
}

i Successfully compiled. but in runtime i found the following error.  
Exception in thread "main" java.lang.NoClassDefFoundError: TestCommand

but same driver URL i safely connecting in netbeans 5.0..... Successfully
running SQL commands & retrieving data.
Daniel Dittmar - 16 Feb 2006 10:54 GMT
> Exception in thread "main" java.lang.NoClassDefFoundError: TestCommand

This means that your own class TestCommand cannot be found through
$CLASSPATH (%CLASSPATH%).

Perhaps you forgot to add the current directory to %CLASSPATH%.

You'll have to add the .jar file of the Oracle driver as well.

Daniel
Shouvik Das - 16 Feb 2006 11:25 GMT
>> Exception in thread "main" java.lang.NoClassDefFoundError: TestCommand
>
[quoted text clipped - 6 lines]
>
>Daniel

Hi,
I was working along with this person. The classes12.zip i.e. the JDBC driver
file has been successfully appended to the CLASSPATH environment variable but
of no use

Signature

Shouvik

Daniel Dittmar - 16 Feb 2006 13:27 GMT
>>> Exception in thread "main" java.lang.NoClassDefFoundError: TestCommand
>> This means that your own class TestCommand cannot be found through
[quoted text clipped - 10 lines]
> file has been successfully appended to the CLASSPATH environment variable but
> of no use

Are you trying to run your code inside of NetBeans or from the command line?

If it is the latter (c:\> java TestCommand), you have to add the
directory containing TestCommand.class to CLASSPATH, (assuming that
TestCommand.java contains no packagage statement).

Java does *not* search the current directory for class files unless your
CLASSPATH contains it.

Daniel
HansF - 17 Feb 2006 03:59 GMT
> Hi,
> I was working along with this person. The classes12.zip i.e. the JDBC driver
> file has been successfully appended to the CLASSPATH environment variable but
> of no use

Silly question, and no insult intended: do you alter the CLASSPATH for
the environment? That is, inside the IDE?

Or - as I have seen some do - with the environment up, set the CLASSPATH
in the environment variables, without restarting the IDE.
Kroll, Michael - 16 Feb 2006 11:31 GMT
Hello,
> Perhaps you forgot to add the current directory to %CLASSPATH%.
>
> You'll have to add the .jar file of the Oracle driver as well.

under NetBeans:

- right mouse click on your project
- select Properties
- select Libraries and add your Oracle Driver

Regards
Michael

Signature

http://www.smurfi.de
German NetBeans-Site

Shouvik Das - 16 Feb 2006 11:41 GMT
>Hello,
>> Perhaps you forgot to add the current directory to %CLASSPATH%.
[quoted text clipped - 9 lines]
>Regards
>Michael

Hi
I did this too but to no result always the Exception raised is
ClassNotFoundException pl help
With regards

Signature

Shouvik

Kroll, Michael - 16 Feb 2006 13:57 GMT
Hello,

saro_77_vlr schrieb:
> Hi,
> i did the following code:
[quoted text clipped - 17 lines]
> }
> }

please try this (I don't have tested):

public static void main(String a[] ) throws SQLException {
    Class.forName(oracle.jdbc.driver.OracleDriver);
        Connection con =
DriverManager.getConnection(jdbc:oracle:thin:@project:1521:proj","project1","admission");

    Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
       ResultSet rs = stmt.executeQuery("select *  from admin");
     System.out.println( rs.getString("regno")) ;
}

Regards
Michael

Signature

http://www.smurfi.de
German NetBeans-Site

saravanan - 17 Feb 2006 03:53 GMT
hi,
it is not working.....

plz help.............

Signature

Saravanan M



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.