请问这个查询有问题
ResultSet rs = stmt.executeQuery("select * from user order by"+var);
我可以得到 var 的 valor,但它不能被执行。var 变量我通过了
<th><a href="ManageUser?action=order&var=nom">Nom</a></a> </th>
在 DAO 我有。
public static ArrayList Order(String var) throws SQLException,ClassNotFoundException
{
ArrayList<User> list=new ArrayList<User>();
Connection con = createDBConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from user order by nom");
int i=0;
while(rs.next())
{
User cb= new User();
cb.setID(rs.getInt(1));
cb.setNom(rs.getString(2));
cb.setPrenom(rs.getString(3));
cb.setEmail(rs.getString(4));
cb.setStatut(rs.getString(5));
cb.setPassword(rs.getString(6));
cb.setDate(rs.getDate(7));
list.add(cb);
i++;
}
stmt.close();
con.close();
return list;
}
请帮忙。