This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Set classpath problem (Oracle9.01)

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using jdk1.4.
I have copied ojdbc14.jar to C:\j2sdk\jre\lib\ext and I can compile Employee.java successfully.
But when I run Employee, got error as
'Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
at Employee.main(Employee.java:18)'
So I run
jar -xvf ojdbc14.jar,
to extract oracle folder inside ojdbc14.jar and copy it to my current working place then I can run Employee, if I delete the oracle folder (which is extracted from ojdbc14.jar) from the current working folder, it won't work again!
I couldn't find out what is wrong, anyone has any idea?
The following is Employee.java
/*
* This sample shows how to list all the names from the EMP table
*
* It uses the JDBC THIN driver. See the same program in the
* oci8 samples directory to see how to use the other drivers.
*/
// You need to import the java.sql package to use JDBC
import java.sql.*;
import oracle.jdbc.*;
class Employee
{
public static void main (String args [])
throws SQLException
{
// Load the Oracle JDBC driver
//DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// 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.
//String url = "jdbc racle:thin:@dog:1521:nan";
//String userName = "nan";
//String password = "nan";
String url = "jdbc racle:thin:@dog:1521 EV";
String userName = "scott";
String password = "tiger";
if (args.length > 0) url = args[0];
if (args.length > 1) userName = args[1];
if (args.length > 2) password = args[2];
Connection conn =
DriverManager.getConnection (url, userName, password);
// Create a Statement
Statement stmt = conn.createStatement ();
// Select the ENAME column from the EMP table
ResultSet rset = stmt.executeQuery ("select ENAME from EMP");
// Iterate through the result and print the employee names
while (rset.next ())
System.out.println (rset.getString (1));
}
}
[ April 05, 2003: Message edited by: nan sh ]
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try to add ojdbc14.jar explicity to the end of your CLASSPATH environment variable?
 
nan sh
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Did you try to add ojdbc14.jar explicity to the end of your CLASSPATH environment variable? "
Yes. It looks like javac can recognize *.jar inside JAVA_HOME\jer\lib\ext, but java cannot, is this the java's behave?
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible that you're running Windows and Microsoft's java.exe is running instead of Sun's java.exe?
What's the result of running java -version from a working directory that is not your [JRE_HOME]/bin folder?
If Microsoft's java.exe is interfering, then you can usually correct this problem by deleting it, renaming it, or specifying the location of Sun's java.exe first in the PATH setting.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic