wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes tablemodel with data from database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "tablemodel with data from database" Watch "tablemodel with data from database" New topic
Author

tablemodel with data from database

Preeti Yarla
Ranch Hand

Joined: Sep 08, 2007
Posts: 69
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 ?


SCJP
Steven Wall
Greenhorn

Joined: Nov 04, 2007
Posts: 22
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.


SCJP, SCWCD
Preeti Yarla
Ranch Hand

Joined: Sep 08, 2007
Posts: 69
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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: tablemodel with data from database
 
Similar Threads
JTable & JDBC
JTable
JTable
JTable
Jtable