+ Reply to Thread
Page 3 of 3 FirstFirst 123
Results 21 to 25 of 25

Thread: Using Java with MySQL on x10

  1. #21
    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 should help: http://www.javaworld.com/javatips/jw-javatip34.html

    Just replace the perl part with php
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  2. #22
    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

    Quote Originally Posted by garrettroyce View Post
    This should help: http://www.javaworld.com/javatips/jw-javatip34.html

    Just replace the perl part with php
    cool, at first glance, this seems to cut to the chase. I'm a big fan of javaworld articles, they have a way of presenting information that Sun could benefit from, with all their spiffy javadoc stuff. javaworld has gotten me "over the hump" on a few occasions.

  3. #23
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Using Java with MySQL on x10

    Quote Originally Posted by fguy64 View Post
    For now I will be embedding the pgn data in the HTML. Where else would the java applet get the data from? Until such time that I can master some kind of communication channel from the java client back to the mySQL server, I don't really see any other option. Unless I'm missing something simple?
    A few of the previously linked pages show the details, but you use a URL to get a URLConnection to get an InputStream, which holds the entity body (eg HTML page) sent by the server.

    As for using HTTP vs <param>, each works in its own way. <param>s mean one less network connection, which means less data transferred because you save on the headers by skipping the second connection. Using HTTP would make it easier to adapt the applet to a standalone app, and would make the means of retrieving and sending game data symmetric.

    For now, do whatever is faster to develop, but (as you design) keep the other method in mind so that you can add it with minimal impact on the code. This means you need an abstraction that can model both getting game data from a <param> and from a web server (and from a file, while you're at it). It should work equally well if the source is set before the app runs (<param> or a predefined web service) or after (user specified web service or file).

  4. #24
    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, we could go on and on with this stuff, I surely don't mind if you don't...

    Quote Originally Posted by misson View Post
    A few of the previously linked pages show the details, but you use a URL to get a URLConnection to get an InputStream, which holds the entity body (eg HTML page) sent by the server.
    I'm not sure I am making myself clear. I'm not saying I have it right, but the main reason I have thought about http from within java is a means to pass data from java to php, and from php to mySQL. When you start talking about InputStream, I am not sure we are on the same wavelength.

    Quote Originally Posted by misson View Post
    As for using HTTP vs <param>, each works in its own way. <param>s mean one less network connection, which means less data transferred because you save on the headers by skipping the second connection. Using HTTP would make it easier to adapt the applet to a standalone app, and would make the means of retrieving and sending game data symmetric.
    Duly noted. As I see it, even if I use <param> as long as I am careful with my design, it won't be a huge amount of work to adapt to standalone. All down the line I have been designing with that in mind, for example, my applet class, and my JFrame class for standalone, are bare shells, it is a JPanel which contains the entire GUI and all the event handlers, and the panel works without modification in both applet and JFrame, This will also be the case when I introduce the new functionality.

    Thanks again, I learn a lot from our discussions.

  5. #25
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Using Java with MySQL on x10

    Quote Originally Posted by fguy64 View Post
    I'm not sure I am making myself clear. I'm not saying I have it right, but the main reason I have thought about http from within java is a means to pass data from java to php, and from php to mySQL. When you start talking about InputStream, I am not sure we are on the same wavelength.
    We do seem to be misunderstanding each other. I was responding to where you said: "For now I will be embedding the pgn data in the HTML. Where else would the java applet get the data from?" The question may have been rhetorical, but it did have an answer:
    Code:
    URL gamesURL=new URL('http://chess.example.com/games');
    URLConnection gamesConn = gamesURL.openConnection();
    InputStream in = gamesConn.getInputStream();
    Anything the server sends is readable from in. An InputStream isn't so useful for character data, but you can wrap it in an InputStreamReader to get characters, and wrap that in a BufferedInputStream to read line-by-line. You were also wondering about sending data to the server, which is similar: you get an output stream and write to it. The JavaWorld article and Sun Java tutorial have the details.

+ Reply to Thread
Page 3 of 3 FirstFirst 123

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