• 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

using of Next and Previous button to display database values

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sir, i am trying to fetch database values and display them in a JTable. I have used DefaultTableModel and somehow managed to display data. I have two JButtons PREVIOUS and NEXT, which need to play their own role. i am maintaining a database table with time as a field. i have corresponding to different times, different values for different fields. i need to fetch those values and display in JTable, which is attached to a scrollpane.

now my problem is that how to perform the next and previous method for the respective NEXT and PREVIOUS JButtons.

Can anyone help me to get out of it. Please give me some suggestion regarding this...
And at the same time is it a good step of using DefaultTableModel? whether i need to use AbstractTableModel? Actually i did not get the full idea of using AbstractTableModel. can you please provide me some suitable examples which is using AbstractTableModel and fetching Database values, not hardcoded.....

Thank you in advance.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code for the Next/Previous button is basically the same as it was to create the table. That is you do an SQL query to get the data and create your table model. Then all you do is use:



to refresh the table so it show the new data.

The DefaultTableModel "is an" AbstractTableModel.
 
partha phukan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you sir for your reply. But sir, whether i need to use different different query to perform the next and previous method to take place. is it possible to with a single query?

if i click the NEXT JButton 6 times then whether i need to write 6 different query and then i am confused how to perform the previous method that as i click the PREVIOUS JButton to display back the same results but in reverse order i.e i mean to say that how to use same query for two different actionPerformed method for the NEXT and PREVIOUS JButtons.

please give me some suggestion... Thank you again..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic