Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

noclassfound error

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i m using following applet for querying oracle database.

import java.sql.*;
import java.awt.*;
import java.applet.*;

/*<applet code="JdbcApplet" archive="jarfile.jar" width=300 height=400>
</applet>*/

public class JdbcApplet extends Applet
{

Connection conn=null;

public void init ()
{
try
{
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:thin:@anant:1521:student", "scott", "tiger");
}
catch(Exception e)
{
System.out.println("connection");
}
}


public void paint(Graphics g)
{
try
{
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("SELECT * FROM emp");
// Dump the result
int y=50;
while (rset.next())
{
String a= rset.getString(1);
g.drawString(a, 100, y);
y=y+10;
}
stmt.close();
}
catch(Exception e)
{
String s = "unable to exeute query";
}
}
}

applet gets compiled .
following error comes when this applet is run


java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
at JdbcApplet.init(JdbcApplet.java:19)
at sun.applet.AppletPanel.run(AppletPanel.java:353)
at java.lang.Thread.run(Thread.java:534)

i m using jsdk1.4.2
and oracle9i

i have included ojdbc14.jar,ojdbc14_g.jar classes111.jar,classes12.jar etc in jar file jarfile.jar.

can anyone find the error that i m commiting.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


i have included ojdbc14.jar,ojdbc14_g.jar classes111.jar,classes12.jar etc in jar file jarfile.jar.


Java doesn't support nested jars*. Put ojdbc14.jar in you classpath and things should work.



(*and incidently - in case you want to put this application into production, Oracle's licence doesn't allow you to redistribute its drivers).
[ May 01, 2007: Message edited by: Paul Sturrock ]
 
mintu kumar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for replying, it works.
but i am still unable to connect to oracle.
i am using following security policy for connecting my applet with access
database. but this policy does not work with oracle.
can you suggest any alternative.

file security.txt contains:

grant
{
permission java.lang.RuntimePermission
"accessClassInPackage.sun.jdbc.odbc";
permission java.util.PropertyPermission
"file.encoding","read";
};


i run my applet as
appletviewer -J-Djava .security.policy=security.txt MyApplet.html
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic