select * from t_user where username like %?%怎么写入程序中
Connectionconn=newConnectionFactory().getConnection(); Stringsql="select*fromt_u...
Connection conn = new ConnectionFactory().getConnection(); String sql = "select * from t_user where username like '%?%'"; PreparedStatement pstm = conn.prepareStatement(sql); pstm.setString(1, partOfName); ResultSet rs = pstm.executeQuery(); 这样写的话 pstm.setString(1, partOfName)就报错 因为?在‘’里面了,'%?%'不用单引号就报语法错误 应该怎么写sql语句?
展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询