`/**
代码片段,根据输入的 String 型的account ,返回数据库表verification的部分信息,以ArrayList形式存储
*/
public ArrayList<HashMap<String,Object>> getBuddyList(String account)
{
// int i = 0;
// ArrayList<String> list = new ArrayList<String>();
ArrayList<HashMap<String,Object>> resultlist = new ArrayList<HashMap<String,Object>>();
// String[] array = null;
Connection connection = null;
try
{
String ql = "select * from verification";
connection = DatabaseUtils.getDatabaseUtils().getConnection();
PreparedStatement pre = connection.prepareStatement(ql);
ResultSet rs = pre.executeQuery();
System.out.println("-------rs!=null--------"+(rs!=null));
System.out.println("-------rs.next()--------"+(rs.next()));
// String[] s = new String[]{"abc","asd","qq","qwer"};
while(rs.next())
{
System.out.println("------resultSet.getString account :--------"+(rs.getString("account").equals(account)));
//if(rs.getString("account").equals(account))
//{
System.out.println("------resultSet.getString account :--------"+(rs.getString("account")));
System.out.println("------resultSet.getString nick :--------"+(rs.getString(3)));
System.out.println("------resultSet.getString trends :--------"+(rs.getString(5)));
HashMap<String,Object> map = new HashMap<String,Object>();
map.put("account", rs.getString("account"));
map.put("nick", rs.getString("nick"));
map.put("avatar", rs.getInt("avatar"));
map.put("trends", rs.getString("trends"));
map.put("sex", rs.getString("sex"));
map.put("age", rs.getInt("age"));
map.put("lev", rs.getInt("lev"));
resultlist.add(map);
//}
//i++;
}
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
DatabaseUtils.getDatabaseUtils().closeConnection(connection);
}
catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return resultlist;
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。