0

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

那么我如何允许小程序做到这一点呢?我知道我不应该直接访问数据库,但我稍后会解决这个问题,我以后需要能够读取文件系统,所以这将是有用的。

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 
4

1 回答 1

0

好吧,有两种可能的解决方案可以解决您的问题: 1. 证明您的小程序以便它可以完全控制 jvm,请查看自我认证的小程序。2. 结合这两个 jar,这在大多数情况下都有效,只需将 mysql 连接器的内容,然后最好在编译后将它们添加到您的 jar 中......或者只是将 mysql 连接器 jar 添加到您的编译构建路径中。

于 2013-08-15T02:24:32.773 回答