Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

jdbc Applet - Access Denied error

3 views
Skip to first unread message

Mart Hugh Rogers

unread,
Oct 13, 1999, 3:00:00 AM10/13/99
to
I am trying to read an Access database from an Applet.
At present the access database is locally hosted.

However the first line in my init routine :

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Generates an "access denied" error. The same code works when
wrapped and built as a Java Application.

Any ideas why I get this error?

Thanks in advance.
mart


-------------------- code snippet ---------------------------
import java.sql.*;
import java.lang.*;
import java.applet.*;

public class AccessDBApplet extends Applet
{
public void init()
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
.
.
.
.
..

-------------------- results snippet ---------------------------
C:\_work\jdbc>c:\jdk1.2.2\bin\appletviewer x.html
java.security.AccessControlException: access denied
(java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc )
at java.security.AccessControlContext.checkPermission(AccessCont
rolConte
xt.java:195) at
java.security.AccessController.checkPermission(AccessController.java,
Compiled Code) at
java.lang.SecurityManager.checkPermission(SecurityManager.java, Compiled
Code) at
java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:142
9) at
sun.applet.AppletSecurity.checkPackageAccess(AppletSecurity.java:173)
at
sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:109)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:124)
at AccessDBApplet.init(AccessDBApplet.java:16)
at sun.applet.AppletPanel.run(AppletPanel.java:333)
at java.lang.Thread.run(Thread.java:479)


--
Mart Hugh Rogers

Reinhard Prehofer

unread,
Oct 13, 1999, 3:00:00 AM10/13/99
to
I guess I have a hint ... but the solution is somewhat more complicated.

What I see, you run into the "sandbox problem" of a browser: an applet is
normally NOT allowed to do any
potentially dangerous actions, might it be (even) printing, accessing the
clipboard, or openening a connection (socket)
back to the server which is different from the normal http protocol.

YOu can easily find out if that's the problem: test your applet with the jdk
appletviewer.
If this runs OK, that we do have that security problem because of the
browser.

there are two ways to get rid of the problem
(1) signed /trusted applets - if you are rather new to Java, then I am
afraid this will rather scare you off.
It's not easy, it typically requires certificates (from Versign) and you
have to take a lot of care what kind of browser and what version you are
using.

I rather recommend step 2 and tell you what we have done for avoiding
similar conflicts:
(2) I see you are using Oracle ... and/but you are using Elixir reports
(which I have never used before).
We let the server create the report - output the file either as html or a
pdf and pass that URL back to the applet where it can easily be opend.
these are allowed applet-operations.

...code fragment ... suppose the following fragment is a method somewhere in
your applet (this
= yourapplet)

URL myURL;
String tpUrl = antwort;
try {
myURL = new URL("http://your-rul/report/report1.pdf");
this.getAppletContext().showDocument(myURL, "Title for this page
....");
} catch (MalformedURLException urlE) {
...
tierpassURL = null;
}
....

hope it helps, reinhard


Mart Hugh Rogers

unread,
Oct 13, 1999, 3:00:00 AM10/13/99
to
In article <7u26e0$k2j$1...@readme.inode.at>, Reinhard Prehofer
<reinhard...@cet.at> writes
[snip]

> We let the server create the report - output the file either as html or a
>pdf and pass that URL back to the applet where it can easily be opend.
>these are allowed applet-operations.

How do you trigger the server to produce a report. Also how do you
synchronise the trigger with the time that the report is ready. In
other words, how do you allow for the fact that report is not ready
instantaneously. Perhaps, it is produced on a frequent basis and you
are happy to read file data which may not be totally in sync with the
database?

Thanks in advance?
--
Mart Hugh Rogers

0 new messages