How to delete data from database by delete item in table

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

How to delete data from database by delete item in table

Postby tamnc » Sun Mar 14, 2010 9:11 pm

Hello everybody, I need helps to solve my trouble. I have mysql database and swt table. All records are displayed in table correctly, but I wanna delete particular row in table at the same time the compatible record in mysql database will be dropped effectively. I've tried several times, It's still a problem for me.
Any help will be appreciated. Thanks a lot. Here are my code for DELETE button.

btnDelete.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int select = table.getSelectionIndex();
try {
Cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Invdatabase","root","12345");
Ps = Cn.prepareStatement("Delete from Employee where EmployeeID='"+select+"'");
final Listener changeTableItemHeight = new Listener() {
public void handleEvent(Event event) {
event.height = (int)(event.gc.getFontMetrics().getHeight() * 1.5);
table.removeListener(SWT.MeasureItem, changeTableItemHeight);
table.addListener(SWT.MeasureItem, changeTableItemHeight);
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
} catch (SQLException e1) {
// TODO Auto-generated catch block
Last edited by tamnc on Fri Mar 26, 2010 7:53 pm, edited 1 time in total.
Posts: 1
Joined: Sun Mar 14, 2010 8:47 pm

Re: Display database in Table

Postby Eric Clayberg » Mon Mar 15, 2010 4:28 am

General questions about using SWT should be posted to the Eclipse SWT newsgroup.
Eric Clayberg
Software Engineering Manager

Author: "Eclipse Plug-ins"
Eric Clayberg
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Return to SWT Designer

Who is online

Users browsing this forum: Google [Bot] and 2 guests