There was an error in this gadget

Tuesday, March 29, 2011

How to get CLOB data extending Spring Stored Procedure interface

declareParameter(new SqlOutParameter(OUT_PARAMETER, Types.CLOB ,null,new SqlReturnType()
{
public Object getTypeValue(CallableStatement cs, int i, int sqlType, String typeName)
throws SQLException
{
try
{
final Clob aClob = cs.getClob(i);
final Reader clobReader = aClob.getCharacterStream();
int length = (int) aClob.length();
char[] inputBuffer = new char[1024];
final StringBuffer outputBuffer = new StringBuffer();
while ((length = clobReader.read(inputBuffer)) != -1)
{
outputBuffer.append(inputBuffer, 0, length);
}
return outputBuffer.toString();
} catch (IOException e)
{
_log.info("Exception in processing the Clob data for retriving ");
throw new SQLException(e.toString());
}

}

}
));

1 comment: