我尝试通过preparestatement查询带有order by statement的select sql,它执行了,但是在打印时,它没有排序。谁来帮帮我?
Connection conn = ConnectionUtils.getConnect();
String sql = "SELECT * FROM student ORDER BY ?";
List<Student> listStudent = new ArrayList<>();
try {
PreparedStatement prepareStatement = conn.prepareStatement(sql);
prepareStatement.setString(1, name);
ResultSet rs = prepareStatement.executeQuery();
while (rs.next()) {
Student student = new Student();
student.setId();
......vv
listStudent.add(student);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return listStudent;
暮色呼如
相关分类