I am an ultra newbie to Java and JDBC. I have recently created a small Java applet that returns some query results from a MySQL DB. The DB is local. The problem is this: when I view an html page containing the applet with the Sun appletviewer, the applet runs problem free, ie perfectly. When I try to view the applet in IE or Netscape, I receive the following error: SQLException:java.sql.SQLException: Cannot connect to MySQL server ... Can anyone explain what the problem is? or perhaps simply clarify whether the problem lies with my JDBC setup or my MySQL setup? Thanks in advance, -MLA
Sun Certified Programmer for the Java 2 Platform 1.4
Applets in a browser run in what is known as a "sandbox" which prevents them from accessing (and corrupting!) files and other resources on the client machine. Applets are only able to open network connections to the machine they were downloaded from, so you should make sure that your MySQL database is running on the same machine as the web server, and that you access it using the same machine name or IP address as you used in your < APPLET > tag.
Problem partially resolved. In my applet code I had the literal ip address ( For example "jdbc:mysql://220.127.116.11:3306/test"), but I replaced this with the hostname ("jdbc:mysql://localhost:3306/test") and this seemed to resolve my problems with Netscape but not IE. Any ideas appreciated Thanks in advance, -MLA