繁体   English   中英

从小程序访问另一个jar中的文件

[英]Accessing files from another jar from applet

我需要访问文件,以便我的applet可以连接到服务器上的MySQL数据库,但是我得到安全例外,说我不能这样做,因为文件在另一个jar(mysql连接器j)中。

那么我该如何允许applet这样做呢? 我知道我不应该直接访问数据库,但是稍后将进行修复,无论如何以后我都需要能够读取文件系统,因此这将非常有用。

security: Grant socket perm for http://media.info/game/MDB/mysql-connector-java-5.1.26-bin.jar : java.security.Permissions@cab783 (
 ("java.net.SocketPermission" "media.info" "connect,accept,resolve")
)

Missing Permissions manifest attribute for: http://media.info/game/MDB/mysql-connector-java-5.1.26-bin.jar
Missing Codebase manifest attribute for: http://media.info/game/MDB/mysql-connector-java-5.1.26-bin.jar
security: Validate the certificate chain using CertPath API
security: SHA-256 finger print: xxxxxxxxxxxxxxxxxxxxxxxx
security: The certificate has expired, need to check timestamping info
security: No timestamping info available
security: The OCSP support is enabled
security: The CRL support is enabled
security: Start comparing to jurisdiction list with this certificate
basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages.class with proxy=DIRECT
network: Connecting http://media.info:80/ with proxy=DIRECT
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages.class with cookie "BX=165sgvd8pd98m&b=3&s=d5"
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages_en.class with proxy=DIRECT
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages_en.class with cookie "BX=165sgvd8pd98m&b=3&s=d5"
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages_en.properties with proxy=DIRECT
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages_en.properties with cookie "BX=165sgvd8pd98m&b=3&s=d5"
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages_en.properties with proxy=DIRECT
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages_en.properties with cookie "BX=165sgvd8pd98m&b=3&s=d5"
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages_en_US.class with proxy=DIRECT
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages_en_US.class with cookie "BX=165sgvd8pd98m&b=3&s=d5"
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages_en_US.properties with proxy=DIRECT
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages_en_US.properties with cookie "BX=165sgvd8pd98m&b=3&s=d5"
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages_en_US.properties with proxy=DIRECT
network: Connecting http://media.info/game/MDB/com/mysql/jdbc/LocalizedErrorMessages_en_US.properties with cookie "BX=165sgvd8pd98m&b=3&s=d5"
network: Connecting http://127.0.0.1:3306/ with proxy=DIRECT
0
Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
couldn't acces table
SQLException: null
java.lang.NullPointerException
    at com.game.database.MySQLAccess.getVals(MySQLAcc.java:97)
    at com.game.math.MathGame.init(game.java:104)
    at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)


network: Connecting 

嗯,有两种可能的解决方案来解决您的问题:1.如果您对applet进行了认证,以便它可以完全控制jvm,请查看自我认证的applet。 2.合并这两个jar,这在大多数情况下都可以使用,只需将mysql连接器的内容,然后大概在编译后将它们添加到您的jar中,或者将mysql连接器jar添加到您的编译构建路径中。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM