日期:2014-05-20 浏览次数:20644 次
package com.itcast;
import java.io.Reader;
import java.util.List;
import com.ibatis.sqlmap.client.SqlMapClient;
public class IStudentDAOImpl implements IStudentDAO {
private static SqlMapClient sqlMapClient=null;
static{
try {
Reader reader = com.ibatis.common.resources.Resources.getResourceAsReader("com/itcast/SqlMapConfig.xml");
sqlMapClient = com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(reader);
reader.close();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public void addStudent(Student student) {
// TODO Auto-generated method stub
}
public List<Student> queryAllStudnet() {
// TODO Auto-generated method stub
List<Student> StudentList =null;
try {
StudentList = sqlMapClient.queryForList("selectAllStudent");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return StudentList;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
IStudentDAO dao=new IStudentDAOImpl();
for(Student student:dao.queryAllStudnet()){
System.out.println(student);
}
}
}