JDBC Like 参数化查询

 

构造SQL 语句:



String sql = "select id,name,age,gender,birth from student where name like ?"; 



参数设值:



PreparedStatement ps = conn.PreparedStatement(sql);



String str = getName();



ps.setString(1,"%" + str + "%");

 

你可能感兴趣的:(jdbc)