Using Java with MySQL on x10

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
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).
 

fguy64

New Member
Messages
218
Reaction score
0
Points
0
OK, we could go on and on with this stuff, I surely don't mind if you don't...

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.

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.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
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.
 
Top