• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I need to get pointed in the right direction

 
Vidya Ishaya
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

...Burton Smith
www.webwisesage.com
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can connect to a database using JDBC.

There are no standard components that have the functionality that you need. Maybe there is a library that does.
 
Rob Spoor
Sheriff
Pie
Posts: 20493
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Posts: 48381
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this thread would sit better on another forum. Let's try the databases forum first.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic