I am an experienced PHP programmer who uses PHP with MySQL.
I am learning Java and would like to write some Java stand-alone
programs (to run on my desktop) that can access a MySQL database
that I have on a webhost.
I don't know where to go to find instructions on how to access a
MySQL database, and how to send SQL instructions, etc.
The second thing is I'd like to write stand-alone Java that can have a GUI
where part (or all) of the GUI is a panel in a frame that is displaying the
contents of a website page. Thus, I can be runnning a stand-alone program
that looks like a regular running program in one part, and in another part
(or maybe the whole part) is actually coming from PHP programs on a webpage.
If you can point me in the right direction so that I can learn how
to do these things, I'd be most grateful.
There are two possibilities for connecting to your database:
1) The MySQL database is publicly accessible. You can use regular JDBC to connect to it. I wouldn't count on it though, as this is a rarity.
2) The MySQL database is only accessible from the web server itself. That means you can't use regular JDBC to connect. You will need to create a layer between the database and the application on the web server. Your web server will behave like a (sort of) web service. You do an HTTP POST or GET to a (PHP) page you created that does the work for you. That page then gives you back the results. I suggest using XML as the MIME type of the generated pages. Also, restrict these pages to not accept any query, because that will create a huge security leak.
In short: create a page for each query you want to perform. Parameters to the queries are not a problem, but do remember to add proper validation in your PHP pages. For example: a GET request to http://yoursite/get_product.php?id=5 would return an XML document with the data of the product with ID 5.