[java] applet + mysql

Started by
3 comments, last by markr 19 years, 5 months ago
I'm trying to make an applet that can connect with mysql.I'm using the jdbc driver and it works fine,when running it in an application.When I tried running it with an applet in a html page,it won't connect.The error is "no suitable driver".I know it has to do with the driver I downloaded.I'm new with applets and don't know what to do.Is it possible to do this in an html applet?? Thanks for any help.
Watamerigonsu
Advertisement
You propably need to "sign" it in order to allow it to acces the jdbc driver. Applets have a very strict security manager.
Why do my programs never work on other computers?
You definitely do not want to do this. It would take so many things to just get it working that you will never get a user to use the applet.

However, if this is just for personal use, I can give you a couple of suggestions. The JDBC driver files must be in the classpath that the applet has access to. The easiest way to do this is to put your applet in an archive file and include the driver files in the same archive. You will also need to sign your applet and ask for permission to make a network connection.
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
Unless that network connection is made to the server where the user just loaded the applet from, in that case you are allowed to make a connection. You should look up applet restrictions on sun's site, that will give you a fairly good idea of the possibilities and limitations.
It should work, provided the MySQL is on the same server hostname as the applet was loaded from.

Ensure that the MySQL JDBC driver is either added to the applet's jar, or in its classpath.

It's a very bad idea to make secure applications this way, because the user could easily reverse engineer the applet and obtain direct access to the database, getting any privileges the applet had on the DB.

Mark

This topic is closed to new replies.

Advertisement