mybatis读取oracle中blob

controller:

 

byte[] blob = commonService.getPersonImage(bean.getIdCard());

String base64 = new String(blob));

service:

TableBean bean = getSqlSessionTemplate().selectOne("getPersonImage", idCard);
return bean.getBlob();

bean:

public Class tableBean {
  private byte[] blob; //误区:不要用java.sql.Blob之类的
  get..
  set..  
}

xml:

<select id="getPersonImage" parameterType="java.lang.String" resultType="tableBean">
        SELECT blobColumn  FROM tableName WHERE idCard=#{idCard,jdbcType=VARCHAR}
    </select>

 

posted @ 2018-09-12 16:51  walle1314  阅读(3131)  评论(0编辑  收藏  举报