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 @ 2020-04-09 17:07  那些年的代码  阅读(1464)  评论(0编辑  收藏  举报