Ibatis and Oracle CLOB



To use a CLOB in your Ibatis typehandler you can use the following code:

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

...

oracle.sql.CLOB clob = oracle.sql.CLOB.getEmptyCLOB();
clob.setString(1, "Your String");

...

}

To extract a CLOB with utf-8 support:

public Object getResult(ResultGetter getter) {

STRUCT struct = (STRUCT) getter.getObject();
oracle.sql.CLOB clob = (oracle.sql.CLOB) struct.getAttributes()[1];

String line;
StringBuilder sb = new StringBuilder();

try {

//make sure to use getCharacterStream and not getASCIStream so special characters are supported
BufferedReader reader = new BufferedReader(clob.getCharacterStream());

while ((line = reader.readLine()) != null) {
sb.append(line).append("n");
}
}

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