简体   繁体   English

Applet与mysql通信中的java.security.AccessControlException

[英]java.security.AccessControlException in applet communicating with mysql

My school's programming club is starting a tutoring program, and I have built a Java applet that students can use to request sessions. 我学校的编程俱乐部正在启动补习程序,并且我建立了一个Java小程序,学生可以使用该小程序来请求会话。 The applet communicates with a database that has a table that stores the availability of the tutors, and shows the user the available times. 该小程序与数据库进行通信,该数据库具有一个表,该表存储教师的可用性,并向用户显示可用时间。

First off: I know it's a bad idea to have an applet communicate directly with a database, for security reasons. 首先,我知道出于安全原因,让applet直接与数据库通信是一个坏主意。 That being said, this is a fairly low-risk situation (nothing "sensitive" is stored on the database), and this solution is only temporary (we don't currently have a server capable of running tomcat, so everything needs to be done client-side). 话虽这么说,这是一种低风险的情况(数据库中没有存储“敏感”内容),并且该解决方案只是暂时的(我们目前没有能够运行tomcat的服务器,因此需要完成所有工作)客户端)。

The applet GUI loads correctly, but throws a java.security.AccessControlException ("java.lang.RuntimePermission" "setContextClassLoader") exception when it initializes the class that tries to access the database, and no data is loaded. 小程序GUI正确加载,但是在初始化试图访问数据库的类且未加载任何数据时,抛出java.security.AccessControlException ("java.lang.RuntimePermission" "setContextClassLoader")异常。 How can I solve this problem? 我怎么解决这个问题?

EDIT: I've changed my code so that the DB communications occur on the same thread as the GUI. 编辑:我已更改我的代码,以便数据库通信发生在与GUI相同的线程上。 Now I'm getting this exception: 现在我得到了这个异常:

Exception in thread "Thread-46" java.lang.NoClassDefFoundError: Could not initialize class com.mysql.jdbc.StringUtils
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:298)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at helpsessions.DBHandler.run(DBHandler.java:53)
at java.lang.Thread.run(Unknown Source)

Applets have a very restricted security model by default, in order to extend the facilities available to the applet you will need to sign the applet, and then write an updated security policy with the extended permissions you require. 小程序默认情况下具有非常严格的安全模型,为了扩展可用于小程序的功能,您将需要对小程序进行签名,然后编写具有所需扩展权限的更新的安全策略。

Your second problem - class not found - is because the driver is not being distributed with the applet. 您的第二个问题-未找到类-是因为驱动程序未随小程序一起分发。

I found this with reference to Java 1.1. 我参考Java 1.1找到了这个。

If you're using an applet, then you must place those JARs and class files in the applet's codebase directory and/or archive locations 如果使用小程序,则必须将这些JAR和类文件放在小程序的代码库目录和/或存档位置中

I'm not sure how relevant is to the latest versions of Java, but I would suggest that is your best option to make the driver Jar available to the applet. 我不确定与Java的最新版本之间的相关性如何,但是我建议这是使驱动程序Jar可用于applet的最佳选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java applet java.security.AccessControlException - Java applet java.security.AccessControlException “java.security.AccessControlException:access denied”执行签名的Java Applet - “java.security.AccessControlException: access denied” executing a signed Java Applet 具有JDBC的Applet-java.security.AccessControlException:访问被拒绝 - Applet with JDBC - java.security.AccessControlException: access denied java.security.AccessControlException:在浏览器上运行小程序时,访问被拒绝 - java.security.AccessControlException: access denied when running applet on browser java.security.AccessControlException:运行小程序时发生 - java.security.AccessControlException: Occured when Running an applet rmi java.security.AccessControlException - rmi java.security.AccessControlException Applet中的Java安全性AccessControlException - Java Security AccessControlException in Applet 使用java.awt.Robot类在applet中进行屏幕捕获时,java.security.AccessControlException - java.security.AccessControlException when using java.awt.Robot class for screen capture in applet Java 8中的新java.security.AccessControlException - New java.security.AccessControlException in Java 8 使用java.security.AccessControlException从javascript调用签名的applet函数:访问被拒绝 - calling signed applet function from javascript with java.security.AccessControlException: access denied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM