The implementation of approach 2 is flawed and since the data is not processed in a streaming fashion anyway, use approach 1. Approach 1 will call the driver's implementation of approach 2 which is probably more accurate and could look something like this:
public static String getString(Clob data) throws SQLException {
StringBuilder sb = new StringBuilder();
char[] cbuf = new char[8192];
int l = 0;
try (Reader r = data.getCharacterStream()) {
while ((l = r.read(cbuf)) > -1) {
sb.append(cbuf, 0, l);
}
} catch (IOException ioe) {
throw new SQLException("Unable to read character stream from Clob.", ioe);
}
return sb.toString();
}
I don't think it will make any difference in performance.