Mysql中 BLOB字段转String的方法

转:http://www.javashuo.com/article/p-cnnxyiff-gx.html

1.经过sql直接转换html

select CONVERT (*** USING utf8) AS userName from usertable;spring

2.经过程序转换(注:本例用的是springmvc包装并返回结果集)sql

String srt2;
   try {
         srt2 = new String((byte[])entry.getValue(),"UTF-8");
          hashmap.put(entry.getKey().toString(), srt2);
    } catch (UnsupportedEncodingException e) {
    e.printStackTrace();
   }mvc

相关文章
相关标签/搜索