`/**
代码片段,根据输入的 String 型的account ,返回数据库表verification的部分信息,以ArrayList形式存储
*/
public ArrayList> getBuddyList(String account)
{
// int i = 0;
// ArrayList list = new ArrayList();
ArrayList> resultlist = new ArrayList>();
// 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 map = new HashMap();
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;
}