0

I'm losing my mind. I've been trying to get a Java Applet working with MySQL, and can't seem to figure out this one problem:

Code:

final String dbClassName = "com.mysql.jdbc.Driver";

final String CONNECTION = "jdbc:mysql://127.0.0.1/db";

Class.forName(dbClassName);

Properties p = new Properties();

p.put("user","<me>");

p.put("password","<pw>");

Connection c = DriverManager.getConnection(CONNECTION,p);

The MySQL database works. I can connect and do things on it with php. I can even run the above code without an applet on the command line, and it works. However, when I try to run it as an applet, things break, and I get the following error:

Stupid error

The applet is served through a php file, and the part that loads the applet is below. I added the "archive=mysql.jar" part after some googling. The jar file is the mysql-connector-for-java-5.08. I'm not entirely sure my context is right, but without this, it gives another error, that jdbc can't be found:

echo("<applet archive=mysql.jar code=Display.class width=2600 height=1600>");
echo("</applet>");

After searching the internet, I found a lot of comments (such as: https://forums.oracle.com/forums/thread.jspa?threadID=1453871) which talked about adding stuff like:

grant codeBase "file:${catalina.base}/webapps/TestServlet/-" {
permission java.net.SocketPermission "127.0.0.1:3306", "connect";
};

I've tried to put variations of this into various places, but nothing has really worked. I'm guessing part of the reason, is I have no idea how to implement the above. For example, what is /webapps/?. I'm currently using AWS EC2, and I'm new to this whole thing. I am also using Tomcat 6.

If anyone has any suggestions I'd really appreciate some help. Even work-around solutions... like if I can call php files from my applet to connect for me, and have the php files return info, that'd also be acceptable. Please try to be detailed in solutions - once again, I'm new to linux-related things.

Thank you!

4

0 回答 0