我有一个静态查询,如 Select * from Emp where Empid in (?)
并且我有该值 (?)。我无法确定这个值。请指导我。如果还有其他需要,请告诉我。
最佳答案
试试这个java代码:
public boolean yourMethod(String yuorValue) {
String sql = "select * from user where fieldName = ?";
PreparedStatement stmt = connection.prepareStatement(sql);
stmt.setString(1, yuorValue);//fieldvalue(1), Your passing value
ResultSet rs = stmt.executeQuery();
return rs.next();
}
关于java - 在静态查询中设置变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21780231/