Hello. I have two "applications" which need access to a MySQL DB simultaneously, and which both need to be up-to-date. One is a Java application which holds certain often-changing data in memory, and writes to the MySQL DB on a timer, and when any large changes are made. The other is HTML/PHP based webpage, and thus obviously doesn't hold any information in memory. Without going deeply into it, the Java application can't update the DB on every change, so my idea is that my webpage would query the Java application when data was requested, and the Java application would respond with data in memory (if it was more up-to-date), or it's own query to the MySQL database.
My question, however, is about the best way to go about doing this. Since the php code isn't "running", so to speak, but rather compiled and performed at runtime, then closed, I can't see a way to have the webpage wait for a response to any requests from Java. Would I necessarily need some type of running application, written in php or java, such that I could wait for responses to queries? If so, what would be the best way to query that program? In either case, what type of interface would be best to be used for this purpose? I can run a telnet server from the Java application via a ServerSocket which waits for requests, but then I'm not sure of the best way to communicate through that medium without opening an actual telnet session.
I know this is alot to ask, and rather open-ended, so to speak, but any suggestions whatsoever, even very minor ones, would be greatly appreciated.
Thanks so much for your time!,
-Jess
[Edit for clarity]
Just to be clear, since I know I can get a little caught up in things... My questions is how to best query a Java application, and wait for a response from the JVM with a webpage. Or, in other words, the most common practice for communicating between two programs. Thanks again!
-Jess
Interaction between PHP -> Java -> MySQL DB
Moderator: General Moderators
Interaction between PHP -> Java -> MySQL DB
Last edited by Jessca on Thu Nov 16, 2006 2:11 pm, edited 1 time in total.
It is listening to a port. That's what I had in mind... I could have sworn I mentioned that, my apologies. --- There are still a number of problems, including the best way to wait for information on the website's end. Do you have any suggestions, or even any terminology so I can find other suggestions myself elsewhere?
Thanks so much for responding!,
-Jess
[Edit]
The idea I had would be to let Java listen on a given port, (which I've already implemented), and allow php to somehow request data through that port and wait for a response (which I'm not sure how to implement). I can do the whole process on the Java end, I'm just not sure how to do it on the php-end. I know there are examples of other applications interacting with eachother out there, and likewise I'm sure there are examples of a website interacting with an application in a similar manner... I'm just not sure how they do it, or where to find out how. Even terminology for that would be great, as I'm sure I could find a wealth of information on google if I had something to look for.
Thanks, so much, once again!,
-Jess
Thanks so much for responding!,
-Jess
[Edit]
The idea I had would be to let Java listen on a given port, (which I've already implemented), and allow php to somehow request data through that port and wait for a response (which I'm not sure how to implement). I can do the whole process on the Java end, I'm just not sure how to do it on the php-end. I know there are examples of other applications interacting with eachother out there, and likewise I'm sure there are examples of a website interacting with an application in a similar manner... I'm just not sure how they do it, or where to find out how. Even terminology for that would be great, as I'm sure I could find a wealth of information on google if I had something to look for.
Thanks, so much, once again!,
-Jess
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
You could look in PayPal's dev kit for PHP which connects and retrieves info using sockets:
https://paypal-toolkit.codebase.ebay.co ... p-0.51.zip
particularly global_config.inc.php
The code is simple enough, if not tight, but don't look for PayPal to offer any understandable documentation
https://paypal-toolkit.codebase.ebay.co ... p-0.51.zip
particularly global_config.inc.php
The code is simple enough, if not tight, but don't look for PayPal to offer any understandable documentation