public Customer getCustomer(String ssNum) throws CustomerHomeException, ClassNotFoundException {
String query = "Select ssn, customer_name from customer ";
ResultSet rs = smt.executeQuery(query);
Customer customer = null;
while (rs.next()) {
if (ssNum.equals(rs.getString("ssn"))) {
customer = new Customer(rs.getString("ssn"), rs.getString("customer_name"));
}
return customer;
}
} catch (SQLException e) {
throw new CustomerHomeException("Failed to create CustomerHome", e);
}
}
从MySQL数据库中return
检索值时放置的语句出现错误。值已经存在。