Interaction between PHP -> Java -> MySQL DB
Posted: Wed Nov 15, 2006 10:15 pm
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
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