我有以下代码在一个类中customerModel
。如何从另一个名为 的类中调用此方法customerController
?
public ArrayList<Customer> search(Customer cust) {
ArrayList<Customer> custs = new ArrayList<Customer>();
Connection connection = GaritsConnectivity.connect();
Tuple<ResultSet, Statement> trs = GaritsConnectivity.read("SELECT * FROM Customer WHERE CustomerID=1", connection);
ResultSet rs = trs.getFirst();
try {
//takes a customer, returns it with the correct ID set
while (rs.next()) {
custs.add(createFromRs(rs));
}
} catch (SQLException ex) {
GaritsConnectivity.manageException("Customer search failure", ex);
}
GaritsConnectivity.doneReading(connection, trs);
return custs;
}
在customerController
类中,我想创建另一个方法,我可以从中调用搜索方法CustomerModel
。
public class customerController....
public boolean search(){
//what goes in here im lost? how can i connect the above search from customerModel to customerController?
}