public void UpdateCustomer(Customer customer) throws CustomerHomeException, ClassNotFoundException{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Mydb";
String user = "user1";
String password = "password";
Connection con = DriverManager.getConnection(url,user,password);
PreparedStatement smt= con.prepareStatement("update customer SET ssn = ? customer_name = ? where ssn = ?");
if(getCustomer.equals(customer.getSocialSecurityNumber()))
smt.setString(1,customer.getSocialSecurityNumber());
smt.setString(2, customer.getName());
smt.setString(3, customer.);
smt.executeUpdate();
smt.close();
con.close();
}
catch (SQLException e){
throw new CustomerHomeException("Failed to create CustomerHome", e);
}
}
但我很困惑如何检索现有 ssn 的值。我也有一个方法 getCustomers 来分别检索特定的客户。会有帮助吗