Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

jdbc applet works from command line but not on web page...

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,
Im pretty new at java, and im trying to create an applet that connects to a database on a remote machine. So far, I have been able to connect to the database if i invoke the appletviewer from the command line like this:
C:\java>appletviewer -J-Djava.security.policy=DbaApplPol.txt protocols.html
where protocols.html looks like this:
<html>
<head>
<title>Protocol Database</title>
</head>
<body>
<APPLET CODE=JdbcApplet2 codebase="." archive="classes111.zip" width="400" height="175">
</APPLET>
</body>
</html>

and JdbcApplet2 is the applet code that connects to the database. I found out that to envoke the applet from the command line, i had to have a file in the same directory called DbaApplPol.txt that has the following lines in it:
grant {
permission java.net.SocketPermission "developer", "resolve";
permission java.net.SocketPermission
"192.168.1.10:1521", "connect,resolve";
};
grant {
permission java.lang.RuntimePermission
"accessClassInPackage.sun.jdbc.odbc";
permission java.util.PropertyPermission
"file.encoding", "read";
};
to grant the applet permission to access the database. This combination of JdbcApplet2 code, DbaApplPol.tx, and invoking the applet from the command line works, and does exactly what it is supposed to do. however, when i load up the web page by itself (not from the command line, just double-click on the icon from my C:\java\protocols.html), the applet does not work. I believe it is because the applet when loaded in the web page cant utilize the DbaApplPol.txt permissions file. So if this is the case, how can I get the browser to recognize the permissions set up in the DbaApplPol.txt file? Or is there some other way people do this?
thanks....

 
First, you drop a couch from the plane, THEN you surf it. Here, take this tiny ad with you:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic