Question

I am pretty basic to link from Java to Database. I link item from Database (I use MS.Access) to Java table (JTable) but when I delete in JTable using this code

int numRows = tblweng.getSelectedRows().length;
for(int i=0; i<numRows ; i++ ) 

((DefaultTableModel)tblweng.getModel()).removeRow(tblweng.getSelectedRow());

it deletes only in Table but not in Database. So how I can remove both of them at the same time I click "Remove Button". Please guide me but don't go too deep I am just a basic here. Thank in advance.

Was it helpful?

Solution

1. click Jtable // row selected
2. get data form dep_Table like 
 int a = dep_Table.getSelectedRow();
 String b = String.valueOf(dep_Table.getValueAt(a, 1)); 
3. What data you want in you get and store in String
4. Connect Database
5. use Delete Query and Delete Data From Database 
6. Reload Table Again

These Few basic Step is Enough for You.. I Think..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top