Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Applets: DriverManager.registerDriver NoClassDefFoundError

Re: Applets: DriverManager.registerDriver NoClassDefFoundError

From: Johann Strauss <strauss_at_earthnet.com>
Date: Mon, 19 May 2003 22:56:58 GMT
Message-ID: <_idya.6430$Io.552677@newsread2.prod.itd.earthlink.net>

"Rauf Sarwar" <rs_arwar_at_hotmail.com> wrote in message news:92eeeff0.0305171538.7b4cdec4_at_posting.google.com...
> 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.
>

> 1) Copy classesxxx.zip to the same directory where JoltData.html is
> located.
>

> 2) Edit JoltData.html and add reference to classesxxx.zip if not
> already present. e.g.,
> <APPLET CODE="JoltData.class" ARCHIVE="classesxxx.zip" ....
>

> 3) You may want to use java thin jdbc driver instead of oci driver.
> This way you can test/run your applet on any machine without Oracle
> client install.
>

> 4) If you use jdbc thin driver, you would need to add
> permission java.net.SocketPermission "hostname" "connect, resolve"
> in your .java.policy file. If you don't have this file in your home
> directory, then use policytool to create one.
>

> Regards
> /Rauf Sarwar

Hello, Rauf!

Thank you so much for you help! I did items #1 and #2 with the result of getting the class registered.

Now, however, I can't make a connection to the database. I am suspecting it is item #4 that you mentioned. I've gotten as far as getting the policy tool up and entering most of the permissions and actions. I'm not sure what the "target" is. I have put in "[hostname]:*" . Is that correct? Next problem is, when I click on done, nothing gets created! Even if I try to update the one in C:\j2sdk1.4.1_02\jre\lib\security, nothing get written back.

Thanks again for your help!

Donna Received on Mon May 19 2003 - 17:56:58 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US