• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

adding/retrieving data to/from a mysql DB

 
Deyna Cegielski
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
reposted as i think i got the wrong section first time around...

just a quick question regarding java and its capabilities with MYSql as i havent had much experience on it (gota book coming this week)

im building a employee database application (database in MYSql, interface in Java obviously) which will allow the user to browse through and perform some functions on the database. the GUI will display all the the information in a record in the database, and there will be some database controls to move through the records (first,back,forward,last) which are likely to be buttons.

my way of thinking is that i need an employee class so that when an employee is created, and employee object is created and this is used to populate an entry in the database. is my way of thinking correct? or am i way off mark...and vice versa for retrieval.

any guidance would be much appreciated. thanks
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is basically it. However, you will have to consider how you will perform your database traversing. Do you get the entire table back into an array of Employees, and then just move through the array, or do you always go back to the database to get the next record. There are trade-offs for both. What do you think might be the trade-offs?

To be honest, this sounds like a college homework assignment. Which would mean that you might not be able to use an ORM tool. Let me know.

Mark
 
Deyna Cegielski
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Mark, you're not far wrong its for a university project (we were given the oppurtunity to chose our own individual projects). we have only briefly looked over database interactivity with Java, but its something that i was interested in giving a go, thats why i havent over complicated the system.

anyways back to the task at hand...retreiving the entire table at once is going to have its storage problems (ok maybe not so much for the number of records this system would likely to be dealing with for me, but theres a potential performance issue there for sure (and this is obviously going to be an aspect i have to consider when looking at the hardware specs of the machines this program *would* run on)). going back to the database each time for a new record sounds like the way to do it for what i want, although this may increase the query times and retreival, i think this is an acceptable loss.

so when i "add" and employee all the information from text boxes, combo boxes, check boxes etc is used to create a instance of the employee object. then this instance is used to insert the data into the table.

one problem i forsee (only briefly thought about it, it may not prove to be quite an obsticle) is keeping track of what record i am on in the database (on entering the program, we will start at 1)

Deyna
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic