Re: please confirm something (jdbc)
On Fri, 30 Nov 2007 03:28:30 +0800, stc wrote
(in article <fin3t2$d5q$1@ss408.t-com.hr>):
"Thomas Kellerer" <YQDHXVLMUBXG@spammotel.com> wrote in message
news:5r8a9eF13k6ibU1@mid.individual.net...
available() cannot be used to retrieve the number of bytes for an
InputStream.
It does not claim to return the length of the underlying stream. Actually
I doubt that it even knows the size of the "source".
You should create your tmp buffer with a fixed size (e.g. new byte[1024]),
then it should work. I'm not sure I understand what you mean with "read()
blocks" but that could well be caused by your buffer of length zero.
That's probably it. I used available() because it gave me what I needed when
called on ByteArrayInputStream so I didn't bother to check the javadocs.
I'll try with a fixed-size buffer tomorrow and see what happens but there's
no reason not to work :-)
Regarding the getBytes(), I can confirm that it works with PostgreSQL 8.1.4
(with 8.1.407 JDBC3 driver).
Thanks for the help...
1.don't try to read the whole blob into memory, process it as a buffered
stream.
I.E
while (rset.next()) {
blob = (oracle.sql.BLOB) rset.getObject(1);
thebuffer = new BufferedInputStream(blob.getBinaryStream());
}
or write it to a temp file.
2. store the size of the blob , in an extra field in the record, it's way
faster to recover
newmessageClob.setString(1, message);
st.setString(1, "");
st.setString(2, "");
st.setString(3, theuser);
st.setString(4, sendto);
st.setString(5, subject);
st.setString(6, "Packingfile.zip");
st.setLong(7, newmessageClob.length());
st.setClob(8, newmessageClob);
st.setBlob(9, newfileBlob);
st.setLong(10, newfileBlob.length());
st.setInt(11, 1);
st.executeUpdate();