write stuff from jTable to mySQL table
I got this jTable jazz in my project, I'm fetching stuff from a mySQL database and populating a bunch of jTables. Now I've found some examples how to use jTable events to track for cell changes and then update, but I'm looking for a less efficient but perhaps simpler to understand method of updating the database from the jTable data through a GUI button.
If I could get an example how to grab all of the data, even the non-changed data, and write it all to an example database, that would be sweet!
At this point I'm just unsure how do I go about getting everything from the jTable efficiently and as simply as possible :)
Re: write stuff from jTable to mySQL table
Quote:
Originally Posted by
MonkeyMan
If I could get an example how to grab all of the data, even the non-changed data, and write it all to an example database, that would be sweet!
At this point I'm just unsure how do I go about getting everything from the jTable efficiently and as simply as possible :)
Doing so is highly dependent upon your data model, and did you try search the net for example? What have you tried? If you just want to load data using a JButton, then write an ActionListener and get the data from the JTable (the API clearly lists several methods for doing so - including getValueAt) then update your database as appropriate using JDBC. Otherwise, while the listener approach may seem difficult, it is much more maintainable and better practice.