Suppose that I have a Class:
class EventTransaction {
.....
private Clob dataXML;
public Clob getDataXML() {
return dataXML;
}
p
Here is code I made a long time ago to convert a Clob to a String. It's meant to be used in a utility class.
public static String convertClobToString(Clob clob) throws IOException, SQLException {
Reader reader = clob.getCharacterStream();
int c = -1;
StringBuilder sb = new StringBuilder();
while((c = reader.read()) != -1) {
sb.append(((char)c));
}
return sb.toString();
}
And if I am not mistaken, to create a Clob you would do something like this
Clob myClobFile = new SerialClob("my string".toCharArray());