查询数据库注意点:

public ResultSet getAddress(Connection con,Address address) throws Exception{
        StringBuffer sb = new StringBuffer("select * from list");
        if(StringUtil.isNotNull(address.getAddlocal())){
            sb.append(" and address like BINARY '%"+ address.getAddlocal()+"%'");
        }else{
            return null;
        }
        PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
        return pstmt.executeQuery();
    }


注意:如果是模糊查询日文或者中文不出来的时候 like 后面加上 BINARY

posted on 2013-05-29 09:15  鱼东鱼  阅读(173)  评论(0编辑  收藏  举报

导航