• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

apllet database connectivity

 
vinod sakpal
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my project needs to read a form from an applet and then send the information to the database.
how do i do this ? because the java's security policy does not allow to access database through applets.
will applet servlets connectivity be helpful and how do i do it?
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're on the right track. Commonly the applet opens a URLConnection to the (J2EE) server it was loaded from and posts the data through that connection. The URLConnection should indicate a JSP or servlet that does the actual database work.
Detailed code is a bit much to post here, but a good J2EE book should have an example.
 
Jon Miller
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been using JDBC with JSP's recently, and I have been wondering about applets and JDBC.
If the security policy is adhered to (i.e the applet code and database are located at the same address) and the JDBC driver used is supported by the browsers JVM. Can I make a direct connection from the applet to the database? and to enable this how do I get the applet to automatically download the driver? Can I simply specify the internet address and driver in the argument to
Class.forName("www.somewhere/org.gjt.mm.mysql.Driver").newInstance();

 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's true that the sandbox would get annoyed if you attempted to do JDBC to a database server at a different address than the http server, but I'm virtually certain that there are JDBC-specific rules as well, so even having the same server address (which tends to be a bit of a security risk) wouldn't help.
A bigger issue is that jdbc drivers almost invariably use tcp/ip ports that will get blocked at someone's firewall.
 
Jon Miller
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim, I hadn't considered firewalls which suddenly make this proposition totally impractical!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic