78498

How to remove item in JTable also remove from Database?

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.

Answer1:

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..

Recommend

  • this.gridApi.refreshInfiniteCache() is not clearing selectedRows
  • Color specific row by rowid
  • Creating multi-line header for JTable
  • Updating JTable
  • Qt table widget, button to delete row
  • Jquery-Bootgrid, Row is null on click
  • Magento not sending forgot password emails
  • How to remove a product from a category magento 1.5
  • How to retrieve Business Component rows in SIebel Open UI PM?
  • python mysqldb delete row
  • Possible to “watch” both HAML and SASS at the same time?
  • How to print columns containing value
  • NUnit 3.0 TestCase const custom object arguments
  • xcode don't localize specific strings
  • Create Instant using a negative year
  • Unable to get column index with table.getColumn method using custom table Model
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • Is there a way to do normal logging with EureakLog?
  • Why querying a date BC is changed to AD in Java?
  • Alert pop up with LWUIT
  • Get one-time binding to work for ng-if
  • Regex thinks I'm nesting, but I'm not
  • What is the “return” in scheme?
  • Fetching methods from BroadcastReceiver to update UI
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • How to disable jQuery.jplayer autoplay?
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Change div Background jquery
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • apache spark aggregate function using min value
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • Sorting a 2D array using the second column C++
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal