|
From: <jue...@we...> - 2004-05-03 16:34:14
|
That looks interesting! I didn't think about overloaded SqlParameter =
constructors before; that definitely makes sense. How to you handle the =
LobCreator lifecycle there? LobCreator.close needs to be invoked after =
PreparedStatement execution (but before transaction completion).
BTW, I've recently refined the LOB support for jdbc.core: There are =
AbstractLobCreatingPreparedStatementCallback and =
AbstractLobStreamingResultSetExtractor classes now (don't we love our =
class naming patterns!), to make LOB handling via JdbcTemplate more =
convenient. Have a look at imagedb's DefaultImageDatabase class for =
usage examples.
There's also a ClobStringType class in our Hibernate support, for =
storing String properties in CLOB fields. That allows to transparently =
store long Strings in Oracle CLOBs respectively MySQL text fields, for =
example. It registers a TransactionSynchronization for the =
LobCreator.close call, so just works within a Spring transaction.
Juergen
-----Original Message-----
From: spr...@li...
[mailto:spr...@li...]On Behalf
Of Thomas Risberg
Sent: Monday, May 03, 2004 2:58 AM
To: spr...@li...
Subject: [Springframework-developer] Exposing LOB support to Jdbc Object
layer
I've recently started to take a closer look at Juergen's LOB handler=20
classes and they look very solid. It would be a shame not exposing them =
to the Jdbc Object package - primarily SqlUpdate. I have started to=20
test a few ideas. I added a constructor accepting a LobHandler to the=20
SqlParameter class. I also added a SqlLobValue class for holding the=20
input stream and the length. This is what the usage would look like:
LobHandler lobHandler =3D new DefaultLobHandler(); // or=20
OracleLobHandler
String sql =3D "insert into docs (doc_id, description , added,=20
document) values(?, ?, ?, ?)";
SqlUpdate su =3D new SqlUpdate(ds, sql);
su.declareParameter(new SqlParameter("id", Types.INTEGER));
su.declareParameter(new SqlParameter("desc", Types.VARCHAR));
su.declareParameter(new SqlParameter("added", Types.DATE));
su.declareParameter(new SqlParameter("lob", Types.BLOB,=20
lobHandler));
su.compile();
Object[] inval =3D new Object[4];
inval[0] =3D new Integer(newId);
inval[1] =3D "Doc One";
inval[2] =3D new java.sql.Date(new Date().getTime());
File in =3D new File("word.doc");
int len =3D (int) in.length();
FileInputStream is =3D new FileInputStream(in);
inval[3] =3D new SqlLobValue(is, len);
int count =3D su.update(inval);
is.close();
A few tweaks to the PreparedStatementCreateorImpl class and this=20
actually ran against both Oracle and PostgreSQL.
I think we could easily support all the different methods that=20
LobHandler supports:
byte[]
BinaryStream
String
AsciiStream
CharacterStream
Any thoughts or ideas?
Thomas
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. =
Take an Oracle 10g class now, and we'll give you the exam FREE.=20
http://ads.osdn.com/?ad_id=3D3149&alloc_id=3D8166&op=3Dclick
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|