如果我有一个带有预备语句的类,当用户按下按钮时如何调用它们。
class updateeButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
name = displayName.getText();
price = bookPrice.getText();
Queries update = new Queries();???????????????????
}
}
不同班级的准备语句
public int update(String price, String name) throws SQLException {
ps2.setString(1, name);
ps2.setString(2, price);
System.out.print("Update - ");
return ps2.executeUpdate();
}
答案 0 :(得分:0)
创建一个对象并使用如下所示的参数调用update方法:
public void actionPerformed(ActionEvent e) {
name = displayName.getText();
price = bookPrice.getText();
Queries update = new Queries();
update.update(price, name);//invoke the method using the object
}