Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

using jdbc with java applet

  Asked By: Techguy    Date: Jun 03    Category: Java    Views: 1918
  

Im trying to use jdbc to connect to a mysql database with a java
applet. Here is my app.html file:

<html>
<body>
<applet code="Drop.class" width=900 height=900></applet>
</body>
</html>

when i compile Drop.java and type in 'appletviewer app.html' im
getting the following error:
java.sql.SQLException: Unable to connect to any hosts due to
exception: java.security.AccessControlException: access denied
(java.util.PropertyPermission file. encoding read ......

Should i include other tags and code in the app.html file please or
am i missing something else?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Randall Franklin     Answered On: Jun 03

I have noticed that I cannot conect to my database  unless I launch the
applet in a page using the URL http://localhost/....
If I use my local machine name for the URL it gives me this exception.
If you want to access  any other server than that which served the page,
you have to get into setting permissions......

 
Answer #2    Answered By: Josie Roberts     Answered On: Jun 03

I have included this code  at the end of file  found in
c/jdk1.3.1_01/jre/lib/security/java.policy:

permission
java.lang.RuntimePermission "accessClassInPackage.sun.jdbc.odbc";
permission java.util.PropertyPermission "file.encoding", "read";

i'm now getting :
java.lang.NullPointerException
at Drop.myMethod(Drop.java:43)
at Drop.init(Drop.java:24)
at sun.applet.AppletPanel.run(AppletPanel.java:344)
at java.lang.Thread.run(Thread.java:484)

 
Didn't find what you were looking for? Find more on using jdbc with java applet Or get search suggestion and latest updates.




Tagged: