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>
梅花香自古寒来