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 / March 2006

Tip: Looking for answers? Try searching our database.

JDBC error

Thread view: 
Anand - 22 Mar 2006 16:05 GMT
people,

I would be really grateful if somebody can help me get this right......

I am working on windows XP service pack 2 as my operating system and I
have oracle 9i installed in the system

the path for my oracle is E:/oracle
the path for JDK 1.5 is E:/java/jdk/bin/

My problem is this..... when i try to connect to the database i get a
error as follows...

E:\Java\jdk\bin>javac dbAccess.java
dbAccess.java:11: package oracle.jdbc.driver does not exist
        DriverManager.registerDriver (new
oracle.jdbc.driver.OracleDriver());

my dbAccess.java file does this..... it gets a name from the database
and displays it... thats all... i want to test the jdbc connection.....

the whole dbAccess.java file is as follows.......

import java.sql.*;
import java.lang.Exception.*;
import java.sql.Connection.*;
import java.io.*;

class dbAccess {
 public static void main (String args [])
 {
      try{

    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

      Connection conn = DriverManager.getConnection
            ("jdbc:oracle:thin:@localhost:1521:nandu", "scott",
"tiger");
                            // @machineName:port:SID,   userid,
password

       Statement stmt = conn.createStatement();
       ResultSet rset = stmt.executeQuery("select * from sample1");
       while (rset.next())
             System.out.println (rset.getString(1));   // Print col 1
       stmt.close();
     }
    catch(Exception e)
    {System.out.println("error");}
    }
}

The SID i entered during installation of oracle 9i is 'nandu' so i hope
i entered it right. I think the connection string is proper....please
help me with the right one if i am wrong...... i think the driver class
files or something cannot be accessed by java..... someone told me to
set the classpath or something for java to read the class files......
he showed me how to do it in linux using export CLASSPATH=$CLASSPATH
something..........but i need to get this working in windows...........

my second problem is i need to access these databases from jsp
pages.... and i want to test them locally on my PC itself.... Oracle 9i
also installed a HTTP server powered by Apache.... but can someone tell
me where to place my jsp pages and java files(in which WEB-INF folder)?
I really have no clue about the location to place them so that i can
test them using http://localhost etc......

someone please take the trouble to help me.... I need to finish a
project by the end of this month and the sooner i learn how to do it...
the better it will be.....

Anand.
IchBin - 22 Mar 2006 18:09 GMT
> people,
>
[quoted text clipped - 30 lines]
>
>     DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

[snip code]
I have never used  DriverManager.registerDriver. I just issue this:

   Class.forName(oracle.jdbc.driver.OracleDriver());

But it really sounds like you Driver is not in the class path.

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

Lee Fesperman - 23 Mar 2006 08:55 GMT
> [snip code]
> I have never used  DriverManager.registerDriver. I just issue this:
>
>     Class.forName(oracle.jdbc.driver.OracleDriver());

I assume you meant:

  Class.forName("oracle.jdbc.driver.OracleDriver");

... since your code above would not compile.

> But it really sounds like you Driver is not in the class path.

It's not in the classpath for the compile, but you wouldn't need it to be if you used
Class.forName().

Signature

Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS  (http://www.firstsql.com)

Anand - 24 Mar 2006 12:56 GMT
thanks a lot.... it did really turn out to be a classpath issue. and i
read old posts in this group and i was able to figure it out. Thanks a
lot for the response
Bill Karwin - 22 Mar 2006 21:15 GMT
> E:\Java\jdk\bin>javac dbAccess.java
> dbAccess.java:11: package oracle.jdbc.driver does not exist
>         DriverManager.registerDriver (new
> oracle.jdbc.driver.OracleDriver());

90% of Java issues are classpath issues.

You need to make sure the Oracle JDBC driver jar file is on the classpath
when you compile that code, and when you use the resulting application.

 javac -cp <path>/ojdbc14.jar dbAccess.java

Where <path> is the location of folder containing that jar.

Regards,
Bill K.


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.