天天看点

Mysql中 BLOB字段转String的方法

1.通过sql直接转换

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

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

String srt2;

   try {

         srt2 = new String((byte[])entry.getValue(),"UTF-8");

          hashmap.put(entry.getKey().toString(), srt2);

    } catch (UnsupportedEncodingException e) {

    e.printStackTrace();

   }

梅花香自古寒来

继续阅读