geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Boynes <jboy...@gluecode.com>
Subject Re: BLOB manipulation - question
Date Mon, 29 Nov 2004 00:49:57 GMT
Gianny Damour wrote:
> Hi,
> 
> I am working on the support of Dependent Value Classes.
> 
> The implementation is rather simple: if a binding is not explicitely 
> defined for a CMP field class (see 
> org.tranql.sql.jdbc.binding.BindingFactory) and if the class implements 
> Serializable, then one assumes that the CMP field is a Dependent Value 
> Class. Such CMP fields are stored into BLOB columns.
> 
> The serialized object is stored into the BLOB via the 
> PreparedStatement.setBinaryStream(int parameterIndex, 
> java.io.InputStream x, int length) method. As a matter of fact, this 
> works with Derby. Yet, it seems that this is not the "correct" way. More 
> accurately, it seems that PreparedStatement.setBlob (int i, Blob x) is 
> the "correct" way.
> 
> Anyone knows if PreparedStatement.setBinaryStream is portable?
> 

LOBs in general are not very portable, especially with Oracle.

The problem with setBlob() is that you need to have the driver create an 
instance for you - you can't just pass in a class that implements that 
interface. That usually involves executing the insert/update statement 
with vendor specific SQL and then obtaining a LOB locator either via 
another select or by using something like Oracle's insert/returning.

setBinaryStream() is the most portable way with the main exception being 
Oracle's thin driver where this will not work if the stream is over 4K 
in length.

--
Jeremy

Mime
View raw message