• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying sql qry in a JTable

 
Scott Cunliffe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • 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:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic