This question would be better suited for the
JDBC forum. Please see
CarefullyChooseOneForum.
I'd say that this approach may fail in some databases. LOBs are usually represented in a client by LOB locator, which is actually some kind of a handle, and I'd generally expect this handle to be valid only in the session in which it was opened. Even if you successfully
test this approach in one database, it might fail in another. Moreover, if you are using connection pooling, chances are that sometimes these two methods will obtain the same physical connection and sometimes not, making this code succeed or fail depending on the behavior of the connection pool. That's not something you'd enjoy untangling once your application got into production.
In any case, what are you trying to achieve? The code you've posted (if it actually works) updates existing CLOB by overwriting its beginning with new data ("string to be updated"). If the original CLOB contained
string longer than your update string, these characters would be left in the CLOB. If this is how it is supposed to work, I'd just modify the code to use one connection and be done with it.
If, on the other hand, you just wanted to overwrite the CLOB with completely new contents, you don't even need to select the old CLOB at all. You could simply create a brand new CLOB in your second method and use that in your
UPDATE statement (and omit call to the first method completely).