一个java参数占位符的问题 不要笑话啊
方法:
public List doQuery(String dname) throws DataAccessException {
StringBuffer sb = new StringBuffer();
sb.append( "select * from AppDepartment where DepName like ? order by ID ");
return this.getJdbcTemplate().query(sb.toString(),
new DeptartmentRowMapper(){dname});
我想把dname赋值给?占位符 这样写不对,应该如何写
谢谢
------解决方案--------------------帮顶
------解决方案--------------------format可以做到:
public List doQuery(String dname) throws DataAccessException {
StringBuffer sb = new StringBuffer();
sb.append( "select * from AppDepartment where DepName like %s order by ID ");
return this.getJdbcTemplate().query(sb.toString().format( "%s ",dname),
new DeptartmentRowMapper(){dname});