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

Trouble with Connector/J in an applet

0 views
Skip to first unread message

apchar

unread,
Nov 13, 2003, 11:41:42 PM11/13/03
to
I'm writing a simple applet to access a remote mysql database (the
mysql server and the web server are on the same machine.) So I'm using
connector/J.

First question: does the driver .jar file need to sit on the machine
where I compile the applet (a mandrake 9.1 linux box), on the web host
that'll dish up the applet (ipowerweb.com), or does everyone who surfs
my website have to download and install connector/J to run this applet
in their browser?

Second question: I'm trying to test my applet locally. Apache and
MySQL are running on my machine. But I'm hitting a security snag with
the classloader. Please consider the following little bit of java
code:
import java.awt.*;
import java.applet.Applet;
import java.sql.*;

public class ShowPost2 extends Applet {
public void init() {
try { Class.forName("org.gjt.mm.mysql.Driver"); }
catch (ClassNotFoundException e) {
e.printStackTrace(); }
}
public void paint(Graphics g) { }
}

and the html file that contains it:

<html>
<head><title>test</title></head>
<body>
<!--<applet code="ShowPost2.class" width="400" height="400"></applet>
-->
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="400" height="400" codetype="application/java">
<param name="code" value="ShowPost2.class">
<param name="type"
value="application/x-java-applet;version=1.3">
<param name="scriptable" value="false">
<embed type="application/x-java-applet;version=1.3"
code="ShowPost2.class" width="400" height="400"
scriptable="false"
pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html">
</embed>
</object>
</body>
</html>

Now on my mandrake 9.1 linux box at work I can load this page just
fine. The web server (apache) and web browser are both running on
localhost. No errors. It just works. But on my mandrake 9.1 box at
home I get (in Konquerors java console):
Java VM version: 1.4.2
Java VM vendor: Sun Microsystems Inc.
KJAS: Exception java.security.AccessControlException: access denied
(java.lang.RuntimePermission getClassLoader) during applet
initialization
java.security.AccessControlException: access denied
(java.lang.RuntimePermission getClassLoader)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
at java.security.AccessController.checkPermission(AccessController.java:401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at java.lang.Class.getClassLoader(Class.java:515)
at org.kde.kjas.server.KJASAppletClassLoader.loadClass(KJASAppletClassLoader.java:276)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at ShowPost2.init(ShowPost2.java:12)
at org.kde.kjas.server.KJASAppletStub$2.run(KJASAppletStub.java:199)
at java.lang.Thread.run(Thread.java:534)

What do I need to change on my home machine to test this applet
locally?
Thanks,
Art.

0 new messages