62,614
社区成员
发帖
与我相关
我的任务
分享
public HashMap getHashmap(String sql){
HashMap<Integer,UserInfo> hashmap = new HashMap<Integer,UserInfo>(200000); //这里初始化200000没有作用啊!!!!
SQLConnect sqlc = new SQLConnect();
ResultSet rs = null;
try{
rs = sqlc.query(sql); //执行查询
while(rs.next()){
int id = Integer.parseInt(rs.getString(1));
String name = rs.getString(2);
String password = rs.getString(3);
int status = Integer.parseInt(rs.getString(4));
UserInfo ui = new UserInfo(id,name,password,status); //记录封装在UserInfo类
hashmap.put(id,ui);
}
}catch(Exception e){
System.out.println(e.getMessage());
}
return hashmap;
}
protected boolean removeEldestEntry(Entry eldest) {
if(size()<=cacheSize)return false;//cacheSize设置成20万
return true;
}