标签:
SQL:select * from students where name like ‘%tommy%‘;
正常的sql如上,是可以直接执行的,
那放到java的P热怕热的Statement中就应该是:
//同时把tommy改成通配符?
PreparedStatement pstmt1 = conn.prepareStatement("select * from student where name like ‘%?%‘");
pstmt1.setString(1,"tommy");//这里居然不通过
PreparedStatement pstmt1 = conn.prepareStatement("select * from student where name like ‘%"+tommy+"%‘");
PreparedStatement pstmt1 = conn.prepareStatement("select * from student where name like ?");
pstmt1.setString(1,"%"+"tommy"+"%");//这里居然不通过
java的PreparedStatement中使用like时的问题
标签:
原文地址:http://www.cnblogs.com/tommy-huang/p/4180130.html