Click to See Complete Forum and Search --> : Security Exceptions


February 25th, 2000, 01:34 PM
Hello,

I recently made a java application which goes into a database using jdbc.odbc.JdbcOdbcDriver. When I converted the app. into an applet I got the following error


Starting!!!
java.security.AccessControlException: access denied (java.lang.RuntimePermission
accessClassInPackage.sun.jdbc.odbc )
at java.security.AccessControlContext.checkPermission(Compiled Code)
at java.security.AccessController.checkPermission(Compiled Code)
at java.lang.SecurityManager.checkPermission(Compiled Code)
at java.lang.SecurityManager.checkPackageAccess(Compiled Code)
at sun.applet.AppletSecurity.checkPackageAccess(AppletSecurity.java:172)

at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:237)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Compiled Code)
at DisplayAlarms01.connectDb(DisplayAlarms01.java:69)
at DisplayAlarms01.start(DisplayAlarms01.java:45)
at sun.applet.AppletPanel.run(Compiled Code)
at java.lang.Thread.run(Thread.java:479)

As far as I can tell the applet does not have permission to access the database object...If this is so how can I grant access to the applet to do this.

If not...then any help would be appreciated

Thanks Joe

P.S.

It would be great if you replied to joem236@mediaone.net instead of the board. I just check my email more often.

kib63613
February 25th, 2000, 06:27 PM
If you use jdbc.odbc.JdbcOdbcDriver in your applet to access the database, it might
be the problem. you may query some JDBC drivers which are implemented in Java.
If the JDBC driver is type 3 or 4, it might be used in the applet for accessing database
in the backend. Otherwise, you may relay your access request and access result in
the middle tier through servlet or other methods.
good luck

R.Saravanan
February 26th, 2000, 10:21 PM
Hi,

Re. JdbcOdbcDriver, it won't work from inside an applet. Reason - ODBC access - somewhere up the hierarchy - will need access to a DLL. Applets are not allowed to load / work with native code - so DLL access will be disabled. Pure Java implementations of the drivers - on the other hand ( also called Thin drivers ) - use network connections to the database hosts - so will work from inside the browser, again, if the browser u tried it from was IE, u can try Microsoft's JdbcOdbc Driver - which will allow the connection ( the driver's name is com.ms.jdbc.odbc.JdbcOdbcDriver ) - with Netscape - the driver HAS to be pure Java.

One more aspect for concern will be that an applet will be allowed to connect ( through a network connection ) - only to the host from where it came - meaning - if ur applet and it's container page are located on a different machine from the server that served ur pages, even a pure Java driver might not help.

Hope that was helpful.

Rgds,

R.Saravanan