更新方法所以,我有一個更新的方法來更新的客戶,它看起來像:如何測試在JDBC
public static Customer UpdateCustomer(Customer customer){
System.out.println("Updating customer ");
try {
statement = connection.createStatement();
statement.executeUpdate("UPDATE customer " + "SET id = " + customer.getCustomerId() + "SET name = " + customer.getName() + "SET tagNo = " + customer.getTagNo() +
"SET telephoneNo = " + customer.getTelephoneNo() + "SET email = " + customer.getEmail() + "SET noOfTimesRecycles = " +
customer.getNoOfTimesRecycled());
} catch (SQLException ex) {
System.out.println("Error in updating customer");
ex.printStackTrace();
}
return customer;
}
我不知道怎麼雖然測試。我所有的錢高達現在的測試位是這樣的:
public static Customer UpdateCustomer(Customer customer){
return UpdateCustomer(customer);
}
public static void main(String [] args)
{
connectTest();
UpdateCustomer(105,"John", 4179, "+4475855216");
closeTest();
}
那麼它給了我錯誤的UpdateCustpmer因爲它預計類型的客戶的東西。
能anyonw幫助我?謝謝
你有堆棧跟蹤嗎? – sadhu
是的,我做的是更新方法 – Sne
只是一句話:你的更新語句不應該更新客戶ID,而是把它作爲一個地方標準,尋找客戶更新 – wxyz