Home > Back-end >  Not as a result, I'm going to get all data from the database, the inside of the print out is on
Not as a result, I'm going to get all data from the database, the inside of the print out is on

Time:09-29

Public static ArrayListArrayList//declare the result set
The ResultSet rs=null;
//to get connection object
The Connection Connection=Basedao. Getconn ();
PreparedStatement pStatement=null;

Try {
If (keyword!=null) {
String SQL="select * from the user where user_name like? The order by user_birthday desc limit? That?" ;
PStatement=connection. PrepareStatement (SQL);
PStatement. SetString (1, "%" + keyword + "%");
PStatement. SetInt (2, (cpage - 1) * count);
PStatement. SetInt (3, count);

} else {

String SQL="select * from user order by user_birthday desc limit? That?" ;
PStatement=connection. PrepareStatement (SQL);
PStatement. SetInt (1, (cpage - 1) * count);
PStatement. SetInt (2, count);

}
Rs=pStatement. ExecuteQuery ();
System. The out. Print (1);
While (rs), next ()) {
System. The out. Print (2);
Sport_user user=new sport_user (
Rs. Get string (" user_id "),
Rs. Get string (" user_name "),
Rs. Get string (" user_pwd "),
User_sex rs. Get string (" "),
User_birthday rs. Get string (" "),
User_moible rs. Get string (" "),
User_idenity rs. Get string (" "),
Rs. Get int (" user_status ")
);
System. The out. Print (0);
System. The out. Print (user);
list.add(user);
};
System. The out. Print (3);
} the catch (Exception e) {
//TODO: handle the exception
} the finally {
System. The out. Print (4);
Basedao. Closeall (rs, pStatement, connection).
}
System. The out. Print (5);
return list;

}

CodePudding user response:

To print only 1234, illustrate the rs collection without the data, you can try to output the rs collection of size, can also according to the parameters passed, execute SQL statements directly to the data, look at what the output record

CodePudding user response:

No 3 that you must fetch the data from the rs error when you need the bai, you catch exceptions to play out and have a look

CodePudding user response:

} the catch (Exception e) {
//TODO: handle the exception
e.printStackTrace();
}

The exception

CodePudding user response:

The debug a open don't know you have the wrong, also have been print

CodePudding user response:

reference 1st floor beetle response:
print only 1234, illustrate the rs collection without the data, you can try to output the rs collection of size, can also according to the parameters passed, execute SQL statements directly to the data, see what the output record

Low-level mistakes thank the kowtow

CodePudding user response:

refer to the second floor moeC response:
no. 3 then you must fetch the data from the rs error when you need the bai, you catch the exception type see

Low-level mistakes thank the kowtow

CodePudding user response:

The
reference 3 floor nayi_224 response:
} the catch (Exception e) {
//TODO: handle the exception
e.printStackTrace();
}

The exception to

Thank you kowtow