| Author |
noclassfound error
|
mintu kumar
Greenhorn
Joined: Apr 28, 2007
Posts: 10
|
|
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 racle: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.
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
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 ]
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
mintu kumar
Greenhorn
Joined: Apr 28, 2007
Posts: 10
|
|
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
|
 |
 |
|
|
subject: noclassfound error
|
|
|