Forums Register Login

JTable & Database , design question, what do you think?

+Pie Number of slices to send: Send
Hi guys,

Q: I have a JTable 5x10 I need to insert the content into a database (and later on retrieve it). Every record has a JTable and every record is unique (there are many records) the JTable will have its own table in the database (segmentsTable) and a KEY.

So: how do I place all the content into the table???

my solution, and please feel free to criticize this idea, is to get all information of each raw and insert it to the db.

like this:

public void save()
{
int row = table.getSelectedRow();
String col0 = table.getValueAt(row, 0).toString(); // Value of 0 is in this Variable
String col1 = table.getValueAt(row, 1).toString(); // Value of 1 is in this Variable
// and so on

// Do insert KEY + raw content
}

so basically I'll have to have a table with 10 attributes and each attribute will contain a raw.

What do you think? I am very new to db so I'm not sure this is the most efficient way to do this. if you know a better way to insert/update/select info from a jtable PLEAES let me know.

Thanks
Ppr
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 687 times.
Similar Threads
JTable & Database , design question, what do you think?
JTable & Database , design question, what do you think?
jtable
JTable usage
Color in JTable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:45:13.