This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC in an Applet?

 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to write an applet that will utilize JDBC. Unfortunately, whenever I try to load the driver for the database, I get an AccessControlException. This is my error message (toString() method invoked on the caught exception):

This is the code that produces that error:

I've pasted the exact same code into another Java application (this one wasn't an applet) and I found that it executes perfectly. From that, I would assume that the security exception I'm getting is due to the limited security access of the Applet.
Is there any way to use JDBC from an Applet?
Thanks,
Corey
[ May 02, 2003: Message edited by: Corey McGlone ]
 
Amol Desai
Ranch Hand
Posts: 82
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, it only skimmed the surface. 2-tier solutions are not good for general internet use. You can use the "Search" feature of this forum to find out more.
 
Dilip Kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
my suggestion is better to write database connection in a servlet, and call that servlet from applet.....
Cheers,
Dilip
 
Manish Hatwalne
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Corey McGlone:

I've pasted the exact same code into another Java application (this one wasn't an applet) and I found that it executes perfectly. From that, I would assume that the security exception I'm getting is due to the limited security access of the Applet.
Is there any way to use JDBC from an Applet?
Thanks,
Corey
[ May 02, 2003: Message edited by: Corey McGlone ]


You are right it is indeed about security. The only solution is to use pure Java drivers instead of jdbc-odbc brdge.
- Manish
 
Manish Hatwalne
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is from JDBC FAQs -
http://java.sun.com/products/jdbc/faq.html#3
HTH,
- Manish
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two problems with using 2-tier database logic in applets.
1. You can only do it from a signed applet
2. JDBC drivers almost invariably use funny TCP/IP ports (SQL Server uses port #1433). The only TCP/IP ports you can expect to always be usable are ports 80 (HTTP) and 443 (HTTPS). Anything else - even the FTP ports (20 & 21) are likely to be firewalled off.
The exact ports that are blocked depend on the combined paranoia of the network administrators of all the networks between (and including) client and server. I've seen banks block almost everything, though SQL Slammer would have bever succeeded if everybody blocked DBMS ports.
3-tier solutions are more complex to design and implement, and may sometimes be less efficient. But they're the only way you can be assured that your applet will work everywhere on the Internet.
 
Nicholas Turner
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your implementing a 2 tier approach why not use the servlet as a database tier and grab a CachedRowSet that you can serialize to a file. the applet reads and de-serializes it makes it changes. you repost and the servlet updates the rowset
this gives the Applet its proper business and UI tier and the servlet the dbase tier
Sounds like a good plan to me and it would save the applet headache which I know far too well
Its not the best approach but neither is an applet
hope this helps a little
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic