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

相關文章
相關標籤/搜索