Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

my applet can't connect to database

 
liana lim
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my applet can't connect to my mysql database. i put my applet class and database in 1 server.

i use this code to connect the database




and here's the error


can anyone tell me how to fix it??
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applets are only allowed to connect to the server they were served from. If the database is on some other server, then the applet needs to be signed. See HowCanAnAppletReadFilesOnTheLocalFileSystem for more detail.
 
liana lim
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i already did it. my applet and my database are on same server
 
liana lim
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I already add java policy on client side with this :

grant codeBase "http://192.168.71.50/-" {
permission java.security.AllPermission;
};

it still can't connect database. help please....
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Policy files can be tricky. Make sure that the one you're making changes to is really being used.

As an aside, you should remove the ".newInstance()" call in the driver initialization.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18002
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There could also be a firewall issue.

Look back in the forum archives about 2 weeks and I've covered this before. Including a rant why most applets have no business operating in 2-tier mode and opening their own JDBC connections.
 
atul anand
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
grant {
permission java.lang.RuntimePermission
"accessClassInPackage.sun.jdbc.odbc";
permission java.util.PropertyPermission
"file.encoding", "read";
};

save this to txt file say ... grantacc.txt


and to command prompt write this'

appletviewer -J-Djava.security.policy=grantacc.txt ur_file.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic