Re: Netscape.security.AppletSecurityException on db Connect

From: Sam Varshavchik <mrsam(at)courier-mta(dot)com>
To:
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Netscape.security.AppletSecurityException on db Connect
Date: 2002-05-30 02:14:10
Message-ID: courier.3CF58AF2.00000413@ny.email-scan.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

PaulU71555(at)aol(dot)com writes:

> Greetings.
>
> I attempt the following in an applet named PWEntry.class and in an application
> named TextInterface.class to connect to a local postgres database named ctfilm
> as user Paul with no password:
>
> url = "jdbc:postgresql://127.0.0.1/ctfilm?user=Paul&password=NONE";
> .
> .
> DriverManager.getConnection(url, "Paul", "");
>
> This works fine from command line application; trying to load the applet into
> Netscape produces this error:
>
> netscape.security.AppletSecurityException: security.Couldn't connect to
> '127.0.0.1' with origin from 'local-classpath-classes'.

This brings back fond memories of my own struggles with browser VMs. Check
the URL that you're using to run the applet. You'll need to explicitly load
http://127.0.0.1/path/to/applet.class, and you're probably using
http://hostname/path/to/applet.class.

Applets can only connect to the same server they're loaded from, else you'll
get this security exception. The security manager isn't smart enough to
know that both hostname and 127.0.0.1 is the same machine.

It's preferrable to code the applet to pull its own URL, and construct the
JDBC URL at runtime, to reflect the applet's server hostname. You'll find
some methods in the Applet class that will give you the applet's URL.

Furthermore, running JDBC from an applet won't work well in every case.
Since JDBC isn't available in the browser's VM, it'll get pulled off the
server. Anyone who runs the applet will essentially end up downloading all
of JDBC from the server. That's probably fine on a LAN, but you don't want
to do that on a low bandwidth dialup connection.

--
Sam

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Joe Shevland 2002-05-30 02:17:20 Re: Netscape.security.AppletSecurityException on db Connect
Previous Message Tim Freund 2002-05-30 02:13:20 Re: Netscape.security.AppletSecurityException on db Connect