[prev in list] [next in list] [prev in thread] [next in thread] 

List:       odtug-java-l
Subject:    RE: JDBC Beginners question
From:       "Robert Clevenger" <robert.clevenger () oracle ! com>
Date:       2002-09-12 22:05:55
[Download RAW message or body]

Not sure why it's not working with the CLASSPATH variable.  If you
are using a JRE vs. a full J2SDK install that could be the issue.

Also, java -classpath is the recommended way since J2SDK 1.2, I just
always use java -classpath %CLASSPATH% just to be safe.

Hope this helps,


Rob


-----Original Message-----
Bob (MED)
Sent: Tuesday, September 10, 2002 2:17 PM
To: Multiple recipients of list ODTUG-JAVA-L


Thanks for your help Rob!

I am using jdk1.3.1_04 
Here is the command line:
	java call_db

When I specified the classpath as an agument to java, it worked fine! I
modified the CLASSPATH environment variable so that it just contained
c:\oracle\ora81\jdbc\lib\classes12.zip;. tried it again and got the same
error. What am I missing? I should not have to pass in the classpath
argument should I?

Thanks!

-----Original Message-----
Sent: Tuesday, September 10, 2002 3:48 PM
To: Multiple recipients of list ODTUG-JAVA-L


What version of the JDK are you using?

What is the command line you are using to execute it?  Maybe the last 
CLASSPATH entry is confusing the VM.

Try just java -classpath c:\oracle\ora81\jdbc\lib\classes12.zip;.
call_db
(assuming that the class call_db is not in a package)

You don't need j2ee.jar or the nls_charset12.jar for what you are using.

Rob



-----Original Message-----
Bob (MED)
Sent: Tuesday, September 10, 2002 12:49 PM
To: Multiple recipients of list ODTUG-JAVA-L


I am brand new to jdbc and have a simple java class that connects to
oracle and prints out a simple result set. I am running on Windows 2000
Oracle 8.1.7
I can compile the class fine, but when I execute it I get the following
error:
	ClassNotFound : oracle.jdbc.driver.OracleDriver
 
The following is my CLASSPATH entry:
	
c:\oracle\ora81\jdbc\lib\classes12.zip;.;c:\j2sdkee1.2.1\lib\j2ee.jar;c:
\oracle\ora81\jdbc\lib\nls_charset12.zip;c:\oracle\ora81\jdbc\lib\oracle
\jdbc\driver

I would appreciate any help you can provide.

TIA

Here is my code:

import java.sql.*;
import java.math.*;
public class call_db {
public static void main(String[] args){
 try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // Load the Oracle JDBC driver

    // Connect to the database
    // You must put a database name after the @ sign in the connection
URL.
    // You can use either the fully specified SQL*net syntax or a short
cut
    // syntax as <host>:<port>:<sid>.  The example uses the short cut
syntax.

  try {
    Connection conn =
      DriverManager.getConnection ("jdbc:oracle:thin:@machine:1521:sid",
"user","password");
  Statement stmt = conn.createStatement();
  ResultSet rs = stmt.executeQuery("Select dummy from dual");
  System.out.println("X \t");
  while (rs.next()) {
    System.out.println(rs.getString("dummy"));
  }

  rs.close();
  stmt.close();
  conn.close();
}
catch (SQLException se) {
   System.out.println("SqlException: " + se.getMessage());
   se.printStackTrace (System.out);
}
}
catch (ClassNotFoundException e) {
   System.out.println("ClassNotFound : " + e.getMessage());
}
} //main
} //class
Thanks to everyone for making ODTUG 2002 a great success!  Plan now
for next year's conference: Loews Miami Beach, Florida, June 22-27,
2003.
-- 
Author: Van Roekel, Bob (MED)
  INET: Robert.VanRoekel@med.ge.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ODTUG-JAVA-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Thanks to everyone for making ODTUG 2002 a great success!  Plan now
for next year's conference: Loews Miami Beach, Florida, June 22-27,
2003.
-- 
Author: Robert Clevenger
  INET: robert.clevenger@oracle.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ODTUG-JAVA-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Thanks to everyone for making ODTUG 2002 a great success!  Plan now
for next year's conference: Loews Miami Beach, Florida, June 22-27, 2003.
-- 
Author: Van Roekel, Bob (MED)
  INET: Robert.VanRoekel@med.ge.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ODTUG-JAVA-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Thanks to everyone for making ODTUG 2002 a great success!  Plan now
for next year's conference: Loews Miami Beach, Florida, June 22-27, 2003.
-- 
Author: Robert Clevenger
  INET: robert.clevenger@oracle.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ODTUG-JAVA-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic