Results 1 to 6 of 6
  1. #1
    madhura2212 is offline Member
    Join Date
    Jul 2010
    Posts
    3
    Rep Power
    0

    Default 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

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    madhura2212 is offline Member
    Join Date
    Jul 2010
    Posts
    3
    Rep Power
    0

    Default

    Is cross posting not allowed..
    Just thought it would help me.. :-|

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    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

  5. #5
    madhura2212 is offline Member
    Join Date
    Jul 2010
    Posts
    3
    Rep Power
    0

    Default

    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 01:40 PM.

  6. #6
    audriusa is offline Member
    Join Date
    Oct 2010
    Posts
    7
    Rep Power
    0

    Default

    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

  1. Populating JTable with 2 arrays (Netbeans)
    By althair in forum AWT / Swing
    Replies: 3
    Last Post: 12-30-2009, 03:05 PM
  2. Populating a JTable
    By toymachiner62 in forum New To Java
    Replies: 2
    Last Post: 10-13-2009, 06:56 AM
  3. JTable and database
    By hendrix79 in forum New To Java
    Replies: 2
    Last Post: 03-09-2009, 11:15 PM
  4. Replies: 11
    Last Post: 02-20-2009, 03:10 AM
  5. Populating a drop down list from a database
    By matpj in forum New To Java
    Replies: 0
    Last Post: 01-19-2009, 01:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •