+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: Using Java with MySQL on x10

  1. #1
    fguy64's Avatar
    fguy64 is offline x10 Sophmore fguy64 is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    218

    Using Java with MySQL on x10

    greetings. I don't need a how to, I was just hoping someone could save me some time by pointing me in the right direction.

    Given that Java, and thus JDBC, is a client side application, and mySQL is server side application, what is the mechanism by which my Java applet can get information from an online database? Presumably there is some additional server side scripting that is required? Maybe I have to use php/html as an intermediary between the java applet and the mySQL database?

    thanks.

  2. #2
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Using Java with MySQL on x10

    This is mostly gibberish to me, but MySQL has a java class to do this for you: http://dev.mysql.com/downloads/connector/j/5.1.html
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  3. #3
    fguy64's Avatar
    fguy64 is offline x10 Sophmore fguy64 is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    218

    Re: Using Java with MySQL on x10

    Thanks Garrett, this looks promising. It'll take some time to decipher the documentation, I'll post back here when I figure some stuff out. Don't hold your breath.

    Only other question I have is, as far as I can tell, server side java is not part of x10's free hosting service?

  4. #4
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Using Java with MySQL on x10

    I've read up on it, and no, server side java is not possible on X10, unless you use the paid VPS service.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  5. #5
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Re: Using Java with MySQL on x10

    I am sure you can use PHP as an intermediary like AJAX and PHP do for JavaScript to access a database on free hosting, nothing special required. However, the proper way, like what garrettroyce said, requires special configurations unavailable on free hosting.
    Last edited by Twinkie; 05-31-2009 at 07:41 PM.

  6. #6
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Using Java with MySQL on x10

    Quote Originally Posted by Twinkie View Post
    I am sure you can use PHP as an intermediary like AJAX and PHP do for JavaScript to access a database on free hosting, nothing special required. However, the proper way, like what garrettroyce said, requires special configurations unavailable on free hosting.
    I thought the MySQL driver for java was a standalone class. I browsed the documentation and that's what I gathered from it. I haven't delved into java much, so it's very likely I'm wrong :P
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  7. #7
    fguy64's Avatar
    fguy64 is offline x10 Sophmore fguy64 is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    218

    Re: Using Java with MySQL on x10

    OK, where I'm going is this. I want my java chess applet to be be able to load and save some kind of chess games.

    lets first of all consider what might be happening with the following page, which uses a java applet to present a chess game. It's a very popular site for online viewing of games, and they have an extensive database.

    http://www.chessgames.com/perl/chessgame?gid=1282672

    here is a key block of code from this page.

    Code:
    <APPLET 
    	codebase="/java/cvd/"
    	archive="Viewer-Deluxe.jar"
    	code="ChessBoard.class" 
    	align="baseline" width="631" height="560"> 
    	<PARAM name=LightSquares value="FFCC99"> 
    	<PARAM name=DarkSquares  value="CC9966"> 
    	<PARAM name=Background   value="EEEEEE"> 
    	<PARAM name=ImagesFolder value="images"> 
    	<PARAM name=PuzzleMode value="off"> 
    	<PARAM name=MayScript value="on"> 
    	<PARAM name=PgnGameFile value="/perl/nph-chesspgn.pgn?gid=1282672&inode=5252598"> 
    </APPLET>
    it would appear that the key line which refers to database is...

    <PARAM name=PgnGameFile value="/perl/nph-chesspgn.pgn?gid=1282672&inode=5252598">

    pgn is a standard format for storing chess games. a single pgn file can hold just one, or many games. The pgn std is a flat text file with various kinds of delimiters.

    given the large number of games these guys have stored, it can't possibly all be a flat text file.

    so what conclusions can we draw from the above code block?
    Last edited by fguy64; 05-31-2009 at 11:32 PM.

  8. #8
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Using Java with MySQL on x10

    I'm guessing that the .pgn file is a perl script that feeds the data to java.

    You probably could use PHP for this as well. Again, I'm no java expert but what I think is happening is java is accessing that file with those parameters and it returns the information in text format that is parsed by java. The data storage is irrelevant, though you're right, a flat text file is extremely slow compared to a SQL server.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  9. #9
    fguy64's Avatar
    fguy64 is offline x10 Sophmore fguy64 is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    218

    Re: Using Java with MySQL on x10 also Perl

    Quote Originally Posted by garrettroyce View Post
    I'm guessing that the .pgn file is a perl script that feeds the data to java.

    You probably could use PHP for this as well. Again, I'm no java expert but what I think is happening is java is accessing that file with those parameters and it returns the information in text format that is parsed by java. The data storage is irrelevant, though you're right, a flat text file is extremely slow compared to a SQL server.
    I like to rephrase stuff, it helps me to understand...

    OK, we're getting somewhere. In this case then, the game was a specific predetermined one for which the site designer had advance knowledge of database keys. SO the designer codes these keys into the html PARAM tage which in turn passes the info to the java applet. So it seems here that Perl acts as an intermediary between HTML and java, and that all the game information is passed to the applet on startup. So java does not concern itself with database access at all, either directly or indirectly.

    There are other cases where the user enter search parameters into an html form. presumably if Perl, or maybe php, would get there parameters and do a search and return the info to java via some code between Applet tags.

  10. #10
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Using Java with MySQL on x10

    Yeah, that wouldn't be an issue at all. You'd have to dynamically generate the param with server side scripting, unless it's possible to use javascript to change the parameters and then restart java, but I have no idea if you can.

    You can probably also save if you can use java to set $_GET or $_POST variables and submit the page to a similar perl or php script that will save into the database.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

+ Reply to Thread
Page 1 of 3 123 LastLast

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. Replies: 14
    Last Post: 09-29-2008, 07:07 PM
  3. New Site-Suggestions?
    By mnoutside in forum Review My Site
    Replies: 9
    Last Post: 08-27-2008, 07:01 AM
  4. Java & mySQL
    By islander in forum Programming Help
    Replies: 1
    Last Post: 03-18-2008, 10:54 AM
  5. Have a problem with my forum
    By tikloos in forum Scripts & 3rd Party Apps
    Replies: 43
    Last Post: 01-19-2006, 01:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers