The Artima Developer Community
Sponsored Link

Java Answers Forum
Database manipulation

2 replies on 1 page. Most recent reply: Jan 11, 2006 2:48 AM by John John

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
John John

Posts: 2
Nickname: javafreak
Registered: Dec, 2005

Database manipulation Posted: Dec 30, 2005 2:40 AM
Reply to this message Reply
Advertisement
I recently retired and decided to try and teach myself Java! I have read a couple of books but find they give very few real situation examples of code used to manipulate databases. I want to write some small programs for my interests and my local sports club and set myself an example task I set up a text file of materials, with a super class (M) and two sub classes, metals (T) and non metals(U). All the materials have four fields ( type (t or u), name (string), properties(string of 8 properties a,b,c,d,e,f.g,h) and weaknesses(string e,f,g,h).

I have been able to print two separate array lists of metals (T) and non metals (U) from my original text file. I am only keeping a relatively small number of materials in my text file and want to carry out a number of comparisons. Firstly I am assuming I have the same number of metals and non metals and want to do the following comparisons:

1.Compare first metal with first non metal, then second metal with second non metal and so on. My printout should show the names of the two items compared and print out only the properties they have in common (not all the properties) plus all the weaknesses they have, removing any duplication (efg + egh = efgh).

2. I want to compare all metals with all non metals in my database printing a list of all pairings with the same information as above.

3. I want to allocate a rating to each comparison to show the one the most alike down to the most unalike. Can I do this by allocating x points to the similar properties and y points to the weaknesses, taking the two away then reprinting my pairing in order of maximum points?

I have read up on the various opersators that should be used but don’t seem to be able to incorporate them in my code and make it work

Thank you


Lynn Hollerman

Posts: 67
Nickname: gmholler
Registered: Mar, 2002

Re: Database manipulation Posted: Jan 5, 2006 11:22 AM
Reply to this message Reply
John John,
What you want to do sounds relatively simple, provided you've got the data in a database. If you haven't chosen one yet, I suggest you try MySQL (http://www.mysql.com). If you're not familiar with database manuipulation or SQL, I suggest a book like the MySQL Cookbook from O'Reilly. The other thing you will need is a JDBC driver - the one for MySQL is on the MySQL site as well. If you're just learning Java, most texts (and many web pages) have samples of programs that connect to a database and get data from it.

A lot of what you're talking about in terms of comparisons sounds more like(to me, at least!) something SQL would do - would might want to look at forums about SQL, or about whatever type of database you decide on.

Lynn.

John John

Posts: 2
Nickname: javafreak
Registered: Dec, 2005

Re: Database manipulation Posted: Jan 11, 2006 2:48 AM
Reply to this message Reply
Thanks very much for your suggestion. Sorry not to thank you earlier but I have been on holiday.

The information I have is contained in a text file with several lines of information as strings. I want to keep this in a text file and not a designated database. From initial reading it looked comparitively easy using "Set Intersection" and similar code but none of the books gave a complete chunk of code to show how to incorporate such instructions.

Regards,

John

Flat View: This topic has 2 replies on 1 page
Topic: Hyperlink in a log window Previous Topic   Next Topic Topic: java problem

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use