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

Issues With com.mysql.jdbc.Driver & java.security.AccessControlException

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am facing problem when i try to access database, when i use localhost it works, but when i use ip it throw with error
<applet archive="taskblocks.jar, mysql-connector-java-5.1.5-bin.jar" code="taskblocks.app.TaskBlocks.class" codebase="." width = "1000" height = "500" >
as i put mysql jar file in root and that jar is also WEB-INF/lib folder. i also have put permission code in catalina policy file

grant codeBase "file:${catalina.home}/webapps/struts/-" {
permission java.net.SocketPermission "192.168.112.1:3306", "connect,resolve";
};

grant codeBase "jar:file:${catalina.home}/webapps/struts/mysql-connector-java-5.1.5-bin.jar!/-" {
permission java.net.SocketPermission "192.168.112.1:3306", "connect,resolve";
};

but it is not working and throwing exception

java.net.SocketException: java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.112.1:3306 connect,resolve)
at com.mysql.jdbc.StandardSocketFactory.unwrapExceptionToProperClassAndThrowIt(StandardSocketFactory.java:407)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:268)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2027)
please help , i am really getting frusted
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applets can only connect to the host were they were served from. So if the HTML page containing the applet tage is served from "http://localhost/", then that's where the applet can connect to. If it's served from "http://192.168.112.1/"; then that's what you must use for the DB as well.

Note that for security reasons it's considered bad design to use JDBC in an applet.
 
Arshad Ali
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your reply , i have already tried with accessing application with remote system same error
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to be clear: The HTML page was served from "http://192.168.112.1/", and the applet was trying to connect to "192.168.112.1"? That's odd, because it should work.

By the way, whatever changes you make to the Catalina policy file are irrelevant, because the applet is governed by the security policy on the client machine (over which the web app has no control).
 
Arshad Ali
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so what could be the solution because it is web application and how can i put some thing in client machine. One idea came in my mind can i access servlet from applet and get response back in applet.
 
Hoo hoo hoo! Looks like we got a live one! Here, wave this tiny ad at it:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic