Applet with JDBC - java.security.AccessControlException: access denied

前端 未结 2 1492
长发绾君心
长发绾君心 2021-01-23 06:37
//JDBC using Applet
/*


*/

import javax.swing.*; //JApplet,JLabel,JButton

import java.applet.*; //         


        
相关标签:
2条回答
  • 2021-01-23 07:23

    You won't be able to run JDBC in an applet without taking steps to give the applet appropriate permissions. The topic is covered in detail by this tutorial from Oracle.

    0 讨论(0)
  • 2021-01-23 07:26

    You wont be able to access ODBC drivers from an (untrusted) applet, same as you wont be able to read the local file system.

    There are "pure Java" JDBC drivers which only need socket permissions. This will work if the database server is available through the same origin ("Same Origin Policy") as the web server that delivered the applet (and there's nothing interfering on the network).

    However, it's probably a bad idea to expose a database over the network to end users. Usually you would expose a safe interface through a web server. Also if the applet is loaded over a network, it's unlikely that you'd want to pick up a locally configured database.

    (The code in the question seems extraordinary long compared to a minimum complete program that expresses the problem, but I could go on for ever criticising code.)

    0 讨论(0)
提交回复
热议问题