Results 1 to 6 of 6
- 07-01-2010, 12:25 PM #1
Member
- Join Date
- Jul 2010
- Posts
- 3
- Rep Power
- 0
Populating Jtable from database - better way?
Hi All,
I have a table in MySQL database.
Is there a way where I can populate a JTable with values from a java bean obnject, which would be getting the values from MySQL table.
Say I have a table named EMPLOYEE with the following details:
1. ID
2. Name
3. Age
4. Address
5. Dept
6. Phone Number
and my Java bean class is Employee which has the following member variables
1. id
2. name
3. age
4. dept
And my JTable should display only the 4 columns out of 6 from MySQL table.
Also I want the table to be auto-refreshed.. the data should be checked for updation.
Which is the best way to do it from the following:
1. Directly read the values from the table using JDBC connection and populate the values into the JTable and poll it using a timer
2. Read the values into a java bean and use a table model to display those values.
Is there any better way to do it?
I am new to Swing so I am unaware of the performance issues related to it.
Would be very thankful for guiding.
Thanks in adavnce.
Madhura
- 07-01-2010, 12:28 PM #2
Crossposter:
Swing - Populating Jtable from database - better wayMath problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 07-01-2010, 12:30 PM #3
Member
- Join Date
- Jul 2010
- Posts
- 3
- Rep Power
- 0
Is cross posting not allowed..
Just thought it would help me.. :-|
- 07-01-2010, 12:32 PM #4
It is not forbidden, but you ask volunteers for help. If you had been given the answer in your other thread, another answer here would be a waste of time.
If you really need to crosspost, be upfront about it and post the links to the other threads to avoid duplicate answers..Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 07-01-2010, 12:37 PM #5
Member
- Join Date
- Jul 2010
- Posts
- 3
- Rep Power
- 0
Same question at:
Swing - Populating Jtable from database - better way
Any help is appreciated on either of the forums..
Thanks! :)Last edited by madhura2212; 07-01-2010 at 12:40 PM.
- 10-05-2010, 02:04 PM #6
Member
- Join Date
- Oct 2010
- Posts
- 7
- Rep Power
- 0
In the past I wrote an application that was rendering JTable from the remote source through the model, getting values through the network when requested. It worked well and solved the problem of how to read only as much data as needed (the table was much larger than the part that is normally visible). JTable only reads as much from the model as it is currently showing. It even did not require to load the data in any bigger chunks than a single line. It was RMI connection but likely results should be similar with JDBC and you naturally have offset and limit constructs that help to tie the model with SQL.
Some trivial caching of already known values could help in the model.
Similar Threads
-
Populating JTable with 2 arrays (Netbeans)
By althair in forum AWT / SwingReplies: 3Last Post: 12-30-2009, 02:05 PM -
Populating a JTable
By toymachiner62 in forum New To JavaReplies: 2Last Post: 10-13-2009, 05:56 AM -
JTable and database
By hendrix79 in forum New To JavaReplies: 2Last Post: 03-09-2009, 10:15 PM -
Populating a combo-box in a JFrame with resultset from database
By matpj in forum AWT / SwingReplies: 11Last Post: 02-20-2009, 02:10 AM -
Populating a drop down list from a database
By matpj in forum New To JavaReplies: 0Last Post: 01-19-2009, 12:14 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks