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

jdbc from an applet

1 view
Skip to first unread message

jrme...@panix.com

unread,
May 18, 2000, 3:00:00 AM5/18/00
to
Hi,

I'm going nuts with this problem. The code (see below) works from an
application, but doesnt' work from the appletviewer or browser (using the
java 1.3 plugin) as I'm getting this exception:

java.security.AccessControlException: access denied
(java.net.SocketPermission XSD00102 resolve)

at java.security.AccessControlContext.checkPermission(Unknown
Source)

at java.security.AccessController.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkConnect(Unknown Source)

at java.net.InetAddress.getAllByName0(Unknown Source)

at java.net.InetAddress.getAllByName0(Unknown Source)

at java.net.InetAddress.getByName(Unknown Source)

at java.net.Socket.<init>(Unknown Source)

at com.sybase.jdbc2.timedio.RawDbio.doConnect(RawDbio.java:88)

at
com.sybase.jdbc2.timedio.InStreamMgr.<init>(InStreamMgr.java:94)

at com.sybase.jdbc2.tds.Tds.login(Tds.java:306)

at
com.sybase.jdbc2.jdbc.SybConnection.tryLogin(SybConnection.java:213)

at
com.sybase.jdbc2.jdbc.SybConnection.regularConnect(SybConnection.java:190)

at
com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:169)

at
com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:122)

at com.sybase.jdbc2.jdbc.SybDriver.connect(SybDriver.java:175)

at java.sql.DriverManager.getConnection(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at com.jrm.appletdemo.AppletPanel.jbInit(AppletPanel.java:49)

at com.jrm.appletdemo.AppletPanel.<init>(AppletPanel.java:24)

at com.jrm.appletdemo.AppletDemo.start(AppletDemo.java:68)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)


here's the code:
SybDriver sybDriver =
(SybDriver) Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
sybDriver.setVersion(com.sybase.jdbcx.SybDriver.VERSION_5);
DriverManager.registerDriver(sybDriver);
System.out.println("seems to be successful");
System.out.println("attempting to establish a connection now...");
Properties props = new Properties();
props.put("user", username);
props.put("password", pw);
props.put("database", database);
Connection con =
DriverManager.getConnection("jdbc:sybase:Tds:XSD00102:2032", props);

Shmooth

unread,
May 18, 2000, 3:00:00 AM5/18/00
to
Is XSD00102 the same machine that the web server sits on (or the same server
that the applet was downloaded from)?

jrme...@panix.com

unread,
May 18, 2000, 3:00:00 AM5/18/00
to
One more thing: the webserver and database are on different machines.

jrme...@panix.com

unread,
May 18, 2000, 3:00:00 AM5/18/00
to
> Is XSD00102 the same machine that the web server sits on (or the same server
> that the applet was downloaded from)?

XSD00102 is a database located on a third machine.

Joseph Weinstein

unread,
May 18, 2000, 3:00:00 AM5/18/00
to jrme...@panix.com
Hi. The basic applet security model is that it can only make connections
back to the machine from which it was downloaded. If you want to do
JDBC from an applet to a DBMS not on the applet-server machine,
you need a type-3 JDBC driver. A type-3 JDBC driver has an all-Java
client driver piece which an applet can download and use. This driver
piece connects to a proxy piece which is running on the webserver
machine. This proxy piece then connects to any DBMS anywhere on the
net, and is the middleman between the JDBC client and DBMS.
For security, management and performance reasons it's usually better to
constrain JDBC to a middle tier such as in a servlet, and use HTML to and
from the client, rather than the space and time involved in downloading a
full general query engine (a JDBC driver) to a client which typically uses
.1% of the capability or classes of the JDBC driver.

Joe Weinstein at BEA

jrme...@panix.com wrote:

--

PS: Folks: BEA WebLogic is in S.F., and now has some entry-level positions for
people who want to work with Java and E-Commerce infrastructure products. Send
resumes to j...@beasys.com
--------------------------------------------------------------------------------
The Weblogic Application Server from BEA
JavaWorld Editor's Choice Award: Best Web Application Server
Java Developer's Journal Editor's Choice Award: Best Web Application Server
Crossroads A-List Award: Rapid Application Development Tools for Java
Intelligent Enterprise RealWare: Best Application Using a Component Architecture
http://weblogic.beasys.com/press/awards/index.htm

Daniel

unread,
May 18, 2000, 3:00:00 AM5/18/00
to
That's your problemino. The applet can only connect to the server from
which it came from. Since the server and database are on different
machines, you will get a security exception.

Of course, applications do not have this restriction.

jrme...@panix.com

unread,
May 19, 2000, 3:00:00 AM5/19/00
to
I have followed Joseph's advice and am using a type 3 driver (the Sybase
driver is type 3) and I added to the properties the PROXY property which
has the URL of the webserver (it's the weblogic server) running on all
factory defaults)

I am now getting and am stuck on the following exception: Any ideas????


java.security.AccessControlException: access denied
(java.util.PropertyPermission http.strictPostRedirect read)

at java.security.AccessControlContext.checkPermission(Unknown
Source)

at java.security.AccessController.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)

at java.lang.System.getProperty(Unknown Source)

at java.lang.Boolean.getBoolean(Unknown Source)

at
sun.net.www.protocol.http.HttpURLConnection.followRedirect(Unknown Source)

at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)

at
sun.plugin.protocol.jdk12.http.HttpURLConnection.getInputStream(Unknown
Source)

at
sun.net.www.protocol.http.HttpURLConnection.getHeaderField(Unknown Source)

at com.sybase.jdbc2.timedio.URLDbio.getURLC(URLDbio.java:291)

at
com.sybase.jdbc2.timedio.TDSTunnellingIS.getIS(TDSTunnellingIS.java:117)

at
com.sybase.jdbc2.timedio.TDSTunnellingIS.read(TDSTunnellingIS.java:64)

at
com.sybase.jdbc2.timedio.TDSTunnellingIS.read(TDSTunnellingIS.java:138)

at com.sybase.jdbc2.timedio.URLDbio.reallyRead(URLDbio.java:183)

at com.sybase.jdbc2.timedio.Dbio.doRead(Dbio.java:243)

at
com.sybase.jdbc2.timedio.InStreamMgr.readIfOwner(InStreamMgr.java:530)

at
com.sybase.jdbc2.timedio.InStreamMgr.doRead(InStreamMgr.java:272)

at
com.sybase.jdbc2.tds.TdsProtocolContext.getChunk(TdsProtocolContext.java:555)

at
com.sybase.jdbc2.tds.PduInputFormatter.readPacket(PduInputFormatter.java:229)

at
com.sybase.jdbc2.tds.PduInputFormatter.read(PduInputFormatter.java:62)

at
com.sybase.jdbc2.tds.TdsInputStream.read(TdsInputStream.java:81)

at
com.sybase.jdbc2.tds.TdsInputStream.readUnsignedByte(TdsInputStream.java:114)

at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1717)

at com.sybase.jdbc2.tds.Tds.processLoginAckToken(Tds.java:2809)

at com.sybase.jdbc2.tds.Tds.doLogin(Tds.java:422)

at com.sybase.jdbc2.tds.Tds.login(Tds.java:349)

at
com.sybase.jdbc2.jdbc.SybConnection.tryLogin(SybConnection.java:213)

at
com.sybase.jdbc2.jdbc.SybConnection.regularConnect(SybConnection.java:190)

at
com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:169)

at
com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:122)

at com.sybase.jdbc2.jdbc.SybDriver.connect(SybDriver.java:175)

at java.sql.DriverManager.getConnection(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at
com.bny.appletdemo.login.jButton1_actionPerformed(login.java:107)

at com.bny.appletdemo.login$1.actionPerformed(login.java:60)

at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown
Source)

at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown
Source)

at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)

at java.awt.Component.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown
Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown
Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

0 new messages