• 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

tablemodel with data from database

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JTable with custom tablemodel extending AbstractTableModel. Data for tablemodel is in a resultset obtained from database. When I start the application (which is just one frame with JTable and few buttons) I get the DB connection, and keep that connection open till I close the application. The functional part of my app is fine. I do three operations on the table. Add row, delete row and update cell.

Every change in my table is sent to the database immediately. So I am thinking, how efficient is it for my app to keep talking to the database for everything? If its not efficient what can I do to improve? (Have some sort of collection and read and write into it ? ) Any help please ?
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only you will be able to tell if it is inefficient. If the user is only changing a few pieces of data (so the number of insert/update statements issued to the database are few), then your implementation would likely work.

But you are correct to worry that your implementation may not scale.

We typically let the user make changes to the grid and then have a Save button that user must click to persist those changes. Usually we will have logic as well that determines which rows have had data changed so that we do not automatically run update statements on every row in the grid.

I hope this helps.
 
Preeti Yarla
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

We typically let the user make changes to the grid and then have a Save button that user must click to persist those changes. Usually we will have logic as well that determines which rows have had data changed so that we do not automatically run update statements on every row in the grid.



Thanks Steven! This info helped!
 
reply
    Bookmark Topic Watch Topic
  • New Topic