简体   繁体   中英

Accessing files from another jar from applet

I need to access files so that my applet can connect to a MySQL database on the server, but I get security exceptions saying that I can't do that because the files are in another jar(mysql connector j).

So how do i allow the applet to do that? I know that I shouldn't access the database directly, but I'll fix that later, I'll need to be able to read the file system later anyway, so this will be useful for that.

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 

Well, there are two possible solutions to your problem: 1. being that you certify your applet so it has full control over the jvm, look into self-certified applets. 2. Combine the two jars, this works in MOST cases, just take the contents of say mysql connector, and add them to your jar prefferably post-compilation... or just add the mysql connector jar into your compilation build-path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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