• 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

Displaying sql qry in a JTable

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have managed to perform sql qry in access db and display in a JTable successfully, however i want the last column boolean to display as a checkbox. Then need the code to loop through the table to check for true/false and get data in column one for true results to update sql table. Any help would be appreciated as i am getting desperate and frustrated.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"scottyboy" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

As for your question, make the values Booleans (notice the upper-case B) instead of booleans, and you should automatically get a checkbox in that column... I don't understand the looping through and getting data in column one part... maybe you could explain what you are trying to do in more detail?

Thanks! and welcome to the JavaRanch!

-Nate
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to create a "Save" button. Then look at the following methods.
JTable getTableModel() - This will get you the model used.
TableModel getRowCount() - return the number of rows to loop.
TableModel getValueAt() - This will give you the value of the row/column.
So within your loop you would have something like this:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic