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 + "%");

 

posted @ 2013-10-08 14:36  若 ♂ 只如初见  阅读(831)  评论(0编辑  收藏  举报