大神求破!
这是数据库连接代码public static Connection getConn(){
Connection con=null;
try {

con = DriverManager.getConnection("jdbc:mysql://localhost:3306/web","root", "ROOT");


}catch (SQLException e) {
e.printStackTrace();
}

return con;
}查询代码如下public List<Text> queryAll() {
// TODO Auto-generated method stub
Connection conn = DBConnection.getConn();
String sql = "select id, title, classfi, body, date,commNum from news where classfi = '2' limit 5000;";
List<Text> texts = new ArrayList<Text>();
try {
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
while(rs.next()){
Text text = new Text();
text.setTextId(rs.getInt("id"));
text.setTitle(rs.getString("title"));
text.setClassfi(Integer.parseInt(rs.getString("classfi").trim()));
text.setBody(rs.getString("body"));
String date = rs.getString("date");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
text.setTime(sdf.parse(date));
text.setAttention(rs.getInt("commNum"));
//text.setTagging(rs.getString("tagging"));
text.setFrom(-1);
texts.add(text);
}
DBConnection.close(rs, ps, conn);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return texts;
}调用此函数时,程序一直陷入此函数中,占用CPU一直为0,占用内存未定不变。但是查询3000条数据时,16秒就得到结果,这是什么原因呢?