Ibatis and Oracle BLOB



Usage of the typehandler inserting a byte[] into the database


public void setParameter(ParameterSetter setter, Object parameter)throws SQLException{


byte[] bytesToBeInserted = (byte[]) parameter;
oracle.sql.BLOB blob = oracle.sql.BLOB.getEmptyBLOB();
blob.setBytes(bytesToBeInserted);
...
setter.setBlob(blob);
}

Transforming a BLOB to a byte[] using an Ibatis typehandler


public Object getResult(ResultGetter getter) throws SQLException {
oracle.sql.BLOB blob = (oracle.sql.BLOB) getter.getBlob();
byte[] bytes = blob.getBytes(0, blob.getLength());
return bytes;
}

Comments are closed.

  • 071 - 82 000 82
  • Rijndijk 137 | 2394 AG Hazerswoude-Rijndijk
DEMO
Oracle Specialized
Java
GlassFish
WSO2
i-bridge
Rabobank
Greencat
Reuma Revalidatie Rotterdam
Robeco
VU Medisch Centrum
CHS
LUMC
TomTom
TKP
NCCW
Erasmus MC
UMCG
VIR
ANWB
BVA Auctions
D-Reizen
STEDIN