This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes jdbc applet works from command line but not on web page... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc applet works from command line but not on web page..." Watch "jdbc applet works from command line but not on web page..." New topic
Author

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

Greg Buron
Greenhorn

Joined: Aug 03, 2001
Posts: 4

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....

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jdbc applet works from command line but not on web page...
 
Similar Threads
Java2 Security Permissions
JApplet System Access
JAAS and Policy files problems
Problem with java database connectivity ?? java expert help needed?
applet works from command line but not in browser...