0
回答
MySQL 为什么result.next()没有取第一条语句
终于搞明白,存储TCO原来是这样算的>>>   
public ArrayList<HashMap<String,Object>> getBuddyList(String account)
{
Connection connection = null;
System.out.println("-------account =  ----------" + (account));
String s = "";
ArrayList<HashMap<String,Object>> list = new ArrayList<HashMap<String,Object>>();
System.out.println("-----------list-----------");
try 
{
String sql = "select * from friendlist where hostaccount = ?";
connection = DatabaseUtils.getDatabaseUtils().getConnection();
PreparedStatement preStatement = connection.prepareStatement(sql);
preStatement.setString(1, account);
ResultSet resultSet = preStatement.executeQuery();
System.out.println("-------resultSet!=null--------"+(resultSet!=null));
System.out.println("-------resultSet.next()--------"+(resultSet.next()));
while(resultSet.next()==true&&resultSet!=null)
{
       System.out.println("***************88888888**********");
   System.out.println("  "+resultSet.getString("buddyaccount"));
s = resultSet.getString("buddyaccount");
String sql_2 = "select * from verification where account = ?";
preStatement = connection.prepareStatement(sql_2);
preStatement.setString(1, s);
System.out.println("%%%%%%%%%%%%"+ s + "%%%%%%%%%%%%%%" );
ResultSet rs = preStatement.executeQuery();
System.out.println("-------rs!=null--------"+(rs!=null));
System.out.println("-------rs.next()--------"+(rs.next()));
while(rs.next()==true&&rs!=null)
{
   System.out.println("@@@@@@@@" +rs.getString("nick"));
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"));
list.add(map);


}
}
close(connection);

catch (Exception e)
{
e.printStackTrace();
}
return list;

}

friendlist表结构

# hostaccount, buddyaccount, number
'abc', 'qq', '1'
'abc', 'qwer', '2'
'abc', 'asd', '3'
'qwer', 'asd', '4'
'qwer', 'qq', '5'
'qwer', '你好', '6'
'qwer', '在水一方', '7'




verification 表结构

# account, password, nick, avatar, trends, sex, age, lev
'abc', '123456', '风', NULL, '风华岁月  我们定义未来', '男', '18', '23'
'asd', '123456', '不想长大', NULL, NULL, NULL, NULL, NULL
'qq', '123456', '茉莉花', NULL, NULL, NULL, NULL, NULL
'qwer', '123456', '浪客剑心', NULL, '天空下起了大雨,淋湿了俄的思绪', '女', '19', '25'
'sunny冰青', '123456', '如你一般的人', NULL, '最怕和在乎的人慢慢变远的过程,真的是发自内心的疼。', '男', '22', '35'
'你好', '123456', '不说年少', NULL, '如果没有你,没有过去我不会伤心', '女', '32', '28'
'在水一方', '123456', '空心菜', NULL, '人生若只如初见,何必再见。', '女', '18', '29'

//当输入为qwer时,输出的buddyaccount这一列只有qq  你好  在水一方  而满足条件的asd并没有输出

举报
sunny冰青
发帖于3年前 0回/736阅

以下是问题补充:

  • @sunny冰青 :***************88888888********** qq %%%%%%%%%%%%qq%%%%%%%%%%%%%% -------rs!=null--------true -------rs.next()--------true ***************88888888********** 你好 %%%%%%%%%%%%你好%%%%%%%%%%%%%% -------rs!=null--------true -------rs.next()--------true ***************88888888********** 在水一方 %%%%%%%%%%%%在水一方%%%%%%%%%%%%%% -------rs!=null--------true -------rs.next()--------true ---------server getBuddyList------0 -----ServerThread-----qwer---------- -----ServerThread-----10---------- ---------server getBuddyList------qwer -------account = ----------qwer -----------list----------- -------resultSet!=null--------true -------resultSet.next()--------true ***************88888888********** qq %%%%%%%%%%%%qq%%%%%%%%%%%%%% -------rs!=null--------true -------rs.next()--------true ***************88888888********** 你好 %%%%%%%%%%%%你好%%%%%%%%%%%%%% -------rs!=null--------true -------rs.next()--------true ***************88888888********** 在水一方 %%%%%%%%%%%%在水一方%%%%%%%%%%%%%% -------rs!=null--------true -------rs.next()--------true ---------server getBuddyList------0 -----ServerThread-----qwer---------- -----ServerThread-----10---------- ---------server getBuddyList------qwer -------account = ----------qwer -----------list----------- -------resultSet!=null--------true -------resultSet.next()--------true ***************88888888********** (3年前)
顶部