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.

Algemeen (9)
GlassFish (49)
Java (58)
Managed Services (10)
Oracle (120)
Private Cloud Hosting (2)
SOA/BPEL/ESB (11)
Software development (92)
Strategie (7)
WSO2 (2)

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

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