aspose file tools*
The moose likes JDBC and the fly likes using Java with an internet based mySQL Server? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "using Java with an internet based mySQL Server?" Watch "using Java with an internet based mySQL Server?" New topic
Author

using Java with an internet based mySQL Server?

Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
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.

thanks.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
OK I have since found this info about a JDBC driver available from mysql.com, so I am looking into this, I guess I'll soon find out if it will resolve my issues.

http://dev.mysql.com/downloads/connector/j/5.1.html
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30758
    
156

Fred,
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?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
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.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30758
    
156

Fred,
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.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Thanks Jeanne.

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.

what do you think?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Nothing in the HTML source would reference SQL: any SQL would be done through the Java code--in this case the applet, or on the server side.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Duly noted David.

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
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Whether or not there's a Java client means nothing about the server side.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
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.

onwards and upwards.

Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using Java with an internet based mySQL Server?