从applet访问另一个jar中的文件

时间:2013-08-15 01:58:48

标签: java mysql jdbc applet nullpointerexception

我需要访问文件,以便我的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 个答案:

答案 0 :(得分:0)

嗯,您的问题有两种可能的解决方案: 1.由于您认证您的applet,因此它可以完全控制jvm,查看自我认证的applet。 2.结合两个罐子,这在大多数情况下工作,只需要把mysql连接器的内容,并将它们添加到你的jar中,可以预先编译...或者只是将mysql连接器jar添加到你的编译构建路径中。 / p>