Currently the blob and clob can be constructed only by resultset. jdbc 4.0 connection object does have methods to construct these methods but the absence of set methods in embedded driver makes these objects (created by connection) useless.
To implement these method I will be making some mdofication in the way behaviour of lob objects.
Currently the lob objects stores data either in an array (or string in case of clob) or a stream is constructed directly on top of linked field in store if the size of the lob stored is found to be more than one page. Side effect of this impelementation is that the life time of lob is restrcited till the transaction in which the objects are fetched.
Client implementation assumes all of it can be kept in main memory but that doesn't looks like a reasonable assumption. I can think of only one solution to handle this, by having a temporary file.
I am thinking of using the temp file from the StoreFactory. StoreFactory has methods to create temporary file.
This is what I was thinking to implement (with assumption that I can use temp files)
setBytes/String methods can use array/string field initially once the size crosses initial threshold the data will be written into the file
and further set methods will operate on file. In case the blob/clob size is smaller than
threshold the data is copied in memory other wise a stream is attached with the object. I haven't checked how this stream is created I am not sure if the stream is always operates on store api as the blob and clob objects remain valid even after closing result set.
setStream methods can return a custom stream which will initially store the data in memory and once the threshold is reached it will use temp file.
While setting the blob/clob into prepared statement internally it will call setString/setBytes in case the data is in memory and setStream in case the temp file is in use.