1 16 package com.ibatis.sqlmap.engine.type; 17 18 import com.ibatis.sqlmap.client.extensions.*; 19 20 import java.io.StringReader ; 21 import java.sql.*; 22 23 public class ClobTypeHandlerCallback implements TypeHandlerCallback { 24 25 public Object getResult(ResultGetter getter) 26 throws SQLException { 27 String value = ""; 28 Clob clob = getter.getClob(); 29 if (clob != null) { 30 int size = (int) clob.length(); 31 value = clob.getSubString(1, size); 32 } 33 return value; 34 } 35 36 public void setParameter(ParameterSetter setter, Object parameter) 37 throws SQLException { 38 String s = (String ) parameter; 39 if (s != null) { 40 StringReader reader = new StringReader (s); 41 setter.setCharacterStream(reader, s.length()); 42 } else { 43 setter.setString(null); 44 } 45 setter.setString((String ) parameter); 46 } 47 48 public Object valueOf(String s) { 49 return s; 50 } 51 52 } 53 | Popular Tags |