I was hoping someone could point me in the right direction. I posted this question with my WebHosting company, but so far no luck.
My web hosting company has good php/mySQL support. Given that java, (and thus JDBC?) is client side, and mySQL is running on a server on the internet, what is the mechanism by which my java applet running on any client browser can get information from an online mySQL database. Do I have to look into some kind of java/php/html interface?
I have been poking around on the net, but so far the only information I have seen is of use to a programmer who has everything on a LAN.
Java doesn't have to be client side. Servlets and JSPs are server side. (Presuming your hosting company supports them.) Are you saying you can't use a servlet and are therefore stuck with an applet?
I have a free hosting service on x10hosting.com, and it does not appear that server side java is one of the services they offer, at least it isn't listed in their services, but I will ask. But I'm pretty sure it's a no go.
Anyways, I hadn't thought about being "stuck" with an applet. This is just a hobby project, I wrote an applet, and now I want to expand the functionality. but I would like it so that anybody on the net can access my project. (it's in my coderanch signature)
My initial impression is that the driver I pointed out above is also a client side thing, therefore inappropriate.
chessgames.com is an example of a website that uses java and database access. I'd like to model my project after this, but at this stage I don't know how they do it.
p.s. there are are all sorts of java classes in the download, so maybe I can get connectivity by incorporating some of these classes into my applet. This will all take time to decipher. I'll post back here when I can decipher the documentation for this download.
To use JDBC the driver jar has to be somewhere. Since it clearly isn't going to be on the server (since it doesn't support it) and requiring it on the client is self defeating, it's kind of a dead end.
I looked at chessgames.com. It doesn't look like they use an applet. AJAX can do wonderful things so it is often necessary to use an applet to get good graphical interactions. And with AJAX, the database requests go back to the source server via a local JDBC call. This doesn't help you of course since your hosting provider doesn't do Java.
perhaps it isn't a dead end. I took a look at the page source for one of the game pages, where you can actually play through a game, and found the following little code block...
this all suugests to me that they do in fact use applets, and that the html PARAM tag is used to pass information to one of the java classes, and that PERL is used for access to a pgn database. (pgn is the standard notation for storing a chess game). Then within the <applet> tags is reference to a jar file. Nothing in the source that I could see to suggest SQL is used though, but I know that in desktop chess applications, a pgn database is usually just a flat text file with different types of delimiters.
ANyways, to try and bring this to a definitive conclusion, based on my limited understanding...
We do know that an applet (client) is being used, the code block I pasted seems to prove it. The question remains, given that server side java delivers content, is the existence of the applet enough to conclude that server side java is not being used somewhere? If so it also seems to imply that java isn't being used for database connectivity either, because that ultimately requires JDBC driver on the client, or Server side java.
David Newton wrote:Whether or not there's a Java client means nothing about the server side.
Well, I consider that to be encouraging. Then the fact that there is a java client in the above example in no way requires there to be any java on the server. Which makes it a non issue that my hosting service does not include server side java. But it does include Perl.
OK, I have since determined that it is a relatively simple matter to use a combination of html and php to feed data from an online mySQL database to my java applet.
As of yet, I don't have a way to send data in the other direction, I am investigating having java call an appropriate html document, and perhaps feed information via the header. I am just guessing about the header part. Or maybe a java applet can send information to a php script directly, I don't know.
Anyways, it looks like I will have a suitable answer without using JDBC. Advice here helped me to decide that JDBC very likely isn't involved in the solution. thanks.
Everybody's invited. Even this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss