This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Applets and the fly likes Accessing a database without using signing or policy file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Accessing a database without using signing or policy file" Watch "Accessing a database without using signing or policy file" New topic

Accessing a database without using signing or policy file

Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

I know accessing a database from Applet has been discussed a lot times in this forum. But I m shortening the scope of my query in the following way explaining my scenario.
A group of company has its separate web sites for its individual businesses that uses MySQL as their backends, separately. Some applets will be developed that can query data from those database and delivered to those companies. They will use those applets in their web pages. A little deploy time modifications are acceptable. Some of those sites are written in PHP, some in ASP and some in JSP/Servlet.
1. I have to find out how is it possible for an applet to access remote databases using the data source names and corresponding name/password.
2. No policy file will be supplied to my client. It's not intranet.
3. Signed applet should be avoided in my findings, as this will only be used if no other option is available.
4. Http Tunnelling is the best way I know, but that is also out of scope in my scenario.
I first tried accessing local database from my Eclipse and its works fine through Eclpise runtime. But Eclipse writes a policy file that gives all permissions to the appletviewer and so it connects to the database without probolem. When I use it from browser or appletviewer from command promt, it can't connect to the database as I expected.
So I thought why don't I jar the database driver with the applet for my mysql database. And so prepared a jar containing my codes and pciked another mysql-connector-java-3.0.9-stable-bin.jar (MySQL driver). BTW, is this not a pure JDBC type 4 driver?
Now still my applet can't access the database. I am looing to my codes whether it has some problem with driver name, but no.
Any other viable solutions? Comments are appreciated.

Ashik Uzzaman
Senior Member of Technical Staff,, San Francisco, CA, USA.
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

Now I thought that okay, local file system will protect the applet with Security Exception naturally. Then what about using data source name as URL? So I used one of my products' mysql host to connect and retrive a simple select statement from applet.

And I get the message --

SQLException when setting up connection: : access denied ( resolve)
I agree. Here's the link:
subject: Accessing a database without using signing or policy file
Similar Threads
Need applet to access a remote database
How to put JDBC driver in applet jar?
Updating Database Remotely through Applet
Trouble running Applet that uses the AS400JDBCDriver
Applet not accessing database while running through browser