You have to create a JTableModel that represents your Table.
Additionally, you might want to create a fillWithData-Methode, that
fills the table with the values from the DB (e.g. select * from table).
Also you have to rewrite the setValueAt-Methode:
public void setValueAt(Object value, int row, int col) {
Vector rowData = (Vector)data.elementAt(row);
rowData.setElementAt(value,col);
data.setElementAt(rowData,row);
String query = 'your update-query for this field'
...the code to send this to your db.
fireTableCellUpdated(row, col);
}
Then create your Swing Code:
e.g.:
JTable table = new JTable(new MyTableModel("select * from table"));
JScrollPane scrollPane = new JScrollPane(table);
If you want to add some new rows to your table, you have to implement
your own methods.
Hope this helps.
Regards Fredy
> i am stucked at a point such that i m getting errors when i try to link
>database to a JTable component in Java..
> What i neeed is a solution to link database and JTable so that i can
>display the contents in database in a table..pls help me...My project
>submission date is fast approaching...
>mail me to nibin012@gmail.com...
> i am stucked at a point such that i m getting errors when i try to link
> database to a JTable component in Java..
> What i neeed is a solution to link database and JTable so that i can
> display the contents in database in a table..pls help me...My project
> submission date is fast approaching...
> mail me to nibin012@gmail.com...
You can use http://butler.sourceforge.net. Try the class
RecordListTable that are a database-aware JTable.
/Fredrik