Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Help SWT table and Database
icon8.gif  Help SWT table and Database [message #523590] Fri, 26 March 2010 23:31
Eclipse UserFriend
Hello, everyone

I am a new user in eclipse. I have a trouble with SWT table and database. The table can display all records from mysql database, but I want to delete particular row from the table and also compatible record will be dropped in mysql database.

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 {
Class.forName("com.mysql.jdbc.Driver");
Cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Invdatabase","root","12345");
Ps = Cn.prepareStatement("Delete from Employee where EmployeeID='"+select+"'");
Ps.executeUpdate();
if(select>-1){
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.clear(select);
table.remove(select);
table.addListener(SWT.MeasureItem, changeTableItemHeight);
}
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
Previous Topic:Help with compiler and AST needed
Next Topic:Goldman Sachs Vice Presidents Speak Java at Great Indian Developer Summit 2010
Goto Forum:
  


Current Time: Thu Mar 27 23:57:14 EDT 2025

Powered by FUDForum. Page generated in 0.02400 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top