mybatis讀取oracle中blob

controller:java

 

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

String base64 = new String(blob));

service:sql

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

bean:spa

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

xml:code

<select id="getPersonImage" parameterType="java.lang.String" resultType="tableBean">
        SELECT blobColumn  FROM tableName WHERE idCard=#{idCard,jdbcType=VARCHAR}
    </select>
相關文章
相關標籤/搜索