Java: PreparedStatement中Like后面的参数

Java: PreparedStatement中Like后面的参数
Select * from table_name where name like '?%' Order by age;
这里Like后面的参数是错误的用法, 要像下面这样使用:
Select * from table_name where name like ? Order by age;

%要放到pstmt中去连接, 如:
pstmt.setString(1, name + "%");

你可能感兴趣的:(Java: PreparedStatement中Like后面的参数)