GeeCON Prague 2014*
The moose likes Applets and the fly likes Issues With com.mysql.jdbc.Driver & java.security.AccessControlException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Applets
Bookmark "Issues With com.mysql.jdbc.Driver & java.security.AccessControlException " Watch "Issues With com.mysql.jdbc.Driver & java.security.AccessControlException " New topic
Author

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

Arshad Ali
Greenhorn

Joined: Nov 29, 2008
Posts: 18
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
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
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.


Ping & DNS - my free Android networking tools app
Arshad Ali
Greenhorn

Joined: Nov 29, 2008
Posts: 18
thanks for your reply , i have already tried with accessing application with remote system same error
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
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

Joined: Nov 29, 2008
Posts: 18
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.
 
GeeCON Prague 2014
 
subject: Issues With com.mysql.jdbc.Driver & java.security.AccessControlException