user1877735
user1877735

Reputation: 1

Is it possible to write an applet that connects to Oracle via JDBC?

I have created a simple applet (Java 1.7.0_07), in which I attempt to connect to an Oracle database (ojdbc6.jar). The applet works fine in my IDE's applet viewer but does not run correctly from the web.

I am getting security exceptions, so I signed the jar file thinking that would fix it but I am still getting security exceptions, namely:

java.security.AccessControlException: access denied ("java.util.PropertyPermission" "oracle.jdbc.RetainV9LongBindBehavior" "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 oracle.jdbc.driver.PhysicalConnection$1.run(PhysicalConnection.java:3147)
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.jdbc.driver.PhysicalConnection.getSystemProperty(PhysicalConnection.java:3143)
    at oracle.jdbc.driver.PhysicalConnection.readConnectionProperties(PhysicalConnection.java:736)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:519)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.ericr.signedApplet.SignedApplet.init(SignedApplet.java:61)
    at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

I have been banging my head against a wall trying to get things in order and there seems to be conflicting information on how to set this up.

So... Is it even possible to do what I am trying to do? If so is there a guide that lets me know what I need to do security-wise in order to get the applet to work correctly when accessed from the web?

Thanks...

Upvotes: 0

Views: 1262

Answers (5)

user919860
user919860

Reputation: 3175

The difference between the two environments could be related to the parameters that you're using for your JVM's. In NetBeans, for my Apache Tomcat server, I clicked on and enabled the option "Use Security Manager" and after that, I saw that I was getting the same exact errors that you were getting for my web server.

To find this option, go to the top menu and click Tools > Server. Then, click on your web server under "Servers" in the left menu. On the right menu, click the "Platform" tab and then disable "Use Security Manager" and that might resolve your problem.

Upvotes: 0

damiankolasa
damiankolasa

Reputation: 1500

You also might want to check out a VJDBC project. It might be what you're looking for.

Upvotes: 0

mrnaza
mrnaza

Reputation: 11

you need to check permission accessing the oracle folder or add user to oracle group

Upvotes: -1

Andrew Thompson
Andrew Thompson

Reputation: 168825

The problem comes down to the AccessControlException. The applet will apparently need to be trusted in order to read the oracle.jdbc.RetainV9LongBindBehavior property.

OTOH it is generally advisable to restrict access to the DB by putting it behind a web service. In that case, the applet can simply connect to the web service at the same site, and do what it needs to.

Upvotes: 2

ruakh
ruakh

Reputation: 183280

It is, or is supposed to be possible to connect to an Oracle database, via JDBC, from an applet; see Chapter 24, "JDBC in Applets", in the Oracle Database JDBC Developer's Guide and Reference for Oracle 10g Release 1 for instructions, or its seeming analogue for Oracle 10g Release 2.

Upvotes: 0

Related Questions