【发布时间】:2013-03-12 10:00:57
【问题描述】:
我有以下代码,属于 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?
}
【问题讨论】:
-
尽快 坏了....
-
创建该方法所属类的对象,并使用该对象调用该方法。
-
如果你已经尝试了很久......为什么现在你需要尽快?
-
对于需要尽快回答的人,您对建议不是很敏感吗?对于任何一个答案或没有最佳答案,都没有 cmets 或 upvotes -.-
标签: java sql database methods arraylist