0

So I have a JApplet that was originally a stand alone program. In order to extend it I've converted it into a JApplet.

What I now want to do is everytime data is submitted to the JApplet I would like the contents inserted into a MySQL database. Now, I have no idea how to do this or even if it can be done but I'd like to give it a go!

The idea is that I'll have a separate PHP page to display data inserted into the JApplet form.

Any solutions, comments or pointers would be very handy as I haven't done this before!

1
  • "So I have a JApplet that was originally a stand alone program. In order to extend it.." ..deploy the app. from a link using Java Web Start. It will be easier for you, and a better experience for the user. I agree with @favoretti that generally neither an applet nor desktop app. should have direct access to the DB. Make them connect via a servlet or similar. Commented Aug 9, 2012 at 0:36

1 Answer 1

2

From what I understand of the whole concept, Applets are client-side executables. So basically if your applet will establish communication with the server (preferably not a direct MySQL connection, but via REST API or other sort of client-server comms) you can insert the data. Otherwise, to address your MySQL database directly from your Java code - you can convert your program to be a servlet and run it in an application container on the server.

Sign up to request clarification or add additional context in comments.

2 Comments

This is very useful to know, thanks! Why is it preferable not to have the applet make a direct MySQL connection (unless it's a servlet)?
Well, if it's a local intranet application you can opt for that as well, if it's an application intended to have MySQL server on internet and client apps anywhere - it will mean you will have to open access to MySQL (although pass-protected) to the whole world, and there are some quite nasty bugs in MySQL auth every now and then. Plus, MySQL runs on a port that can be blocked by various ISPs. So choice is up to you of course and depends on the solution that you're trying to build and its goals.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.