String s="abcd"; // The user that needs to be excluded in the table,
the string can be dynamic.
String sql="SELECT Username,Email FROM login where not
Username=userName"; //here I use the query not to exclude the particular user.
PreparedStatement pst = con.prepareStatement(sql);
ResultSet rs = pst.executeQuery();
while(rs.next()){
inputString=(String)rs.getString("Username");
model.addRow(new Object[{rs.getString("Username"),rs.getString("Email"),false});
}
但是生成的结果为空,其他用户的详细信息也被排除。
答案 0 :(得分:1)
尝试修改后的查询,并如下所述动态地传递参数。
// The user that needs to be excluded in the table, the string can be dynamic.
String s="abcd";
//here I use the query not to exclude the particular user.
String sql="SELECT Username,Email FROM login where Username != ?";
PreparedStatement pst = con.prepareStatement(sql);
pstatement.setString(1, s);
ResultSet rs = pst.executeQuery();