How do I send data from a JTable to my DB?

0

I have a filled JTable and need to store its data in a table in my database. How do I do that? I only know the reverse path (fill a table from the DB) I'm using MySQL

    
asked by anonymous 21.12.2014 / 19:37

1 answer

0

You will need to do the following:

  • Connect to the database using the appropriate credentials and the corresponding JDBC driver.
  • For each line of the JTable map the data to a record to be written (this can be an Object Array where each Object receives the value of the JTable cell)
  • Save the record using PreparedStatment
  • Close the connection to the database
  • That's all

        
    21.12.2014 / 19:45