• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to know which record to update?

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I know what record to update? Yes, I realize this depends on how I design everything else. I'm using an algorithm based on position in the file for the recNo. I read strings out of the file, and populate the table model. Right now I am not putting the recNo as a column in the table model. My GUI uses a text box to get the customer number, and based on the line in the JTable that is highlighted, will want to update the database file that the record is now reserved. But I lost the recNo to use. I thought about building a map of JTable row to database recNo, but then wasn't sure how to keep that updated if I allow the columns to be sorted. Could be cheap and remove column sorting. Or I could add recNo as a column in the JTable, and use that, sorta like how the upc value is used in the "Denny DVD" example.

Can anyone provide any thoughts?
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's better to have record number on client side. It saves from lot of work. Using JTable row number may not be a good idea. You could manage row number in sorting but what if some user deletes a record? Add a hidden column for record number in data display table.


Shafique
 
Jason Hocker
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I looked for how to hide a column, but could not see a good way. Would you be able to provide an example? Thanks!
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can remove a JTable column without removing data from model using the following method:

public void removeColumn(TableColumn aColumn)

Regards,
 
Jason Hocker
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont know how I missed that. I didnt know how the TableColumn class and others. Thanks!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic