File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes a bit of help needed for an XML/JDBC assignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "a bit of help needed for an XML/JDBC assignment" Watch "a bit of help needed for an XML/JDBC assignment" New topic
Author

a bit of help needed for an XML/JDBC assignment

Dieter Stryker
Greenhorn

Joined: Mar 21, 2009
Posts: 11
I have a homework assignment asking to generate an XML document which displays results from a database holding results from Lacrosse games.
(the actual requirement in the assignment is as follows: "The root element is obviously the lacrosse tag. Within the document there are a list of team elements that represent individual teams. For each team there are the total number of wins and losses and a list of opponent elements that contain the name of the opponent team, whether their game was played at home (the team’s field) or away (the opponents field), the number of goals the team scored (for) and the number of goals the opponent scored (against). Do all of your database connecting and accesses through a java class. Then use the class to isolate the JDBC calls away from the XML building. I have set up a database and table with the following parameters for access and query.")

The database results table structure is provided as:

Column Data __Type

game_id______Integer
home_team___String
away_team___String
home_score___Integer
away_score___Integer
game_note____String


The XML document should be displayed as:
<lacrosse>
<title>College Lacrosse Results</title>
_<team>
____team_name
____<wins>number of wins</wins>
____<losses>number of losses</losses>
____<opponent>
_________opponent_name
_________<location>home or away</location>
_________<for>goals scored</for>
_________<against>goals given up</against>
____</opponent>
____<opponent>
____:
____</opponent>
____:
_</team>
_<team>
_:
_</team>
</lacrosse>


Part of the assignment notes to "Be sure to handle the overall win-loss record and home/away designations of the games correctly. They are not
explicitly handled in the database table, you will have to compute those values based on the data record itself (i.e.,
whether the team name is indicated in the home or away team column).
"



I'm hoping someone can give me some guidance for the logic of the last paragraph here, which is bolded above. I haven't gotten to coding yet - still looking at the design. OF course, I don't want the specific answer, but just some pointers in the right direction would be appreciated. Thanks.

Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

The ending paragraph sounds to me like "Get all the data via JDBC, but do the log/processing in pure Java". It basically means the database isn't a magic place with all the answers, some have to be done by hand. I don't know if that exactly holds true in this assignment though since... there's always 'some' way to do it via the DB, even if its a bad idea. Granted most teachers wouldn't know a bad query if it stood up and waved, so as with most student assignments "If it compiles, it must work"


My Blog: Down Home Country Coding with Scott Selikoff
Dieter Stryker
Greenhorn

Joined: Mar 21, 2009
Posts: 11
Scott Selikoff wrote:The ending paragraph sounds to me like "Get all the data via JDBC, but do the log/processing in pure Java". It basically means the database isn't a magic place with all the answers, some have to be done by hand. I don't know if that exactly holds true in this assignment though since... there's always 'some' way to do it via the DB, even if its a bad idea. Granted most teachers wouldn't know a bad query if it stood up and waved, so as with most student assignments "If it compiles, it must work"

I'm still not seeing exactly how this process should be performed.

Can anyone help me with the logic of extracting the MySQL data, what type of object to store it in, and whether I should use DOM or SAX (it has to be one of these) to create the XML document...?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a bit of help needed for an XML/JDBC assignment