Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Applets: DriverManager.registerDriver NoClassDefFoundError
dkm32_at_hotmail.com (Donna) wrote in message news:<25032dfc.0305160920.5fc30f5d_at_posting.google.com>...
> Basically, I can get a Java Program to work, but an applet with the
> same code fails. I'm running j2sdk 1.4.1.02 under Windows 2000, with
> Oracle 9i and Internet Explorer 6.0.
>
> CreateJoltData is just a plain Java program; JoltData is an Applet
> (Included below). Both use the same statement to register the Oracle
> Driver. It's the one that is used in all of the books and the Oracle
> webpages:
> DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
>
> I can connect and access an Oracle database from the Java program
> (CreateJoltData)...but not the Applet (JoltData).
>
> If I use the Classpath: .;C:\oracle\ora92\jdbc\lib\classes12_g.zip:
> - The program compiles and executes just fine.
> - The Java Applet compiles but gets a runtime error that usually
> means that the Classpath is not set correctly:
> java.lang.NoClassDefFoundError: orable/jdbc/OracleDriver.
>
> If I use the Classpath: .;C:\oracle\ora92\jdbc\lib\ojdbc14_g.zip
> (which Oracle recommends), both the program and the applet get a
> compile error:
> Package Oracle.jdbc does not exist.
>
> Any help would greatly be appreciated!!!
>
> Donna
>
> ------------------ JoltData.java:
>
> /* JoltData
> compile: javac JoltData.java
> execute: JoltData.html
> */
> import java.applet.*;
> import java.awt.*;
> import java.io.*;
> import java.sql.*;
> import oracle.sql.*;
> import oracle.jdbc.*;
>
> public class JoltData extends Applet {
>
> String database= "Coffee";
> String username = "Donna";
> String password = "v1v1enne";
> Connection conn=null;
>
> // Constructor
> public JoltData () {
> System.out.println("username " +username );
> System.out.println("password " +password );
> registerDB();
> connectDB();
> }
>
> // Register Driver
> private void registerDB() {
> System.out.println("registerDB " );
> try {
> DriverManager.registerDriver(new
> oracle.jdbc.OracleDriver());
> System.out.println("registerDB done.");
> } catch (Exception e) {
> System.err.println("problems registering .");
> }
> }
>
> // Connect To Database
> private void connectDB() {
> System.out.println("connectDBURL." );
> try {
> conn = DriverManager.getConnection
> ("jdbc:oracle:oci8:@" + database,
> username,
> password);
> // Create a statement
> Statement stmt = conn.createStatement ();
> stmt = conn.createStatement();
> System.out.println("connectDB: Connection done. ");
> } catch (Exception e) {
> System.err.println("connectDB: problems connecting to
> database. ");
> }
> }
>
> public void main (String[] args) {
> JoltData converter = new JoltData ();
> }
> }
If you are testing your applet using appletviewer then there are few things that you can look into.
Regards
/Rauf Sarwar
Received on Sat May 17 2003 - 18:38:42 CDT
![]() |
![]() |