Bryan Pendleton wrote:
I vaguely recall discussions of
such an algorithm during the LOB locator development, so there may
in fact be such code in the client, but it's not working for some
reason or another.
Thank you Bryan for looking at this. Is the LOB locator development
relevant to parameters being sent from the client or only LOBs being
returned from the server?
As I type this in, I realize that I'm fuzzy on whether this
drain processing would be trigger by the server or by the client.
Does the server have enough context to know when the client is
done with one statement and moving on to the next?
It needs to be triggered by the server I think. After execution, any
streams set in the parameters need to be drained, but as I think about
this more I don't really understand how things would work with multiple
parameters if the parameter is only partially read from the network
server stream. It does seem to work ok as long as the streams are
consumed by the server. (See attached TestBlobMultipleParam.java).
Kathey
import java.sql.*;
import java.io.*;
public class TestBlobMultipleParam {
public static void main(String args[]) throws Exception {
Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
Connection conn =
DriverManager.getConnection("jdbc:derby://localhost:1527/wombat;create=true;traceFile=trace.out");
conn.setAutoCommit(false);
Statement s = conn.createStatement();
try {
s.executeUpdate("drop table testing");
} catch (SQLException se) {}
s.executeUpdate("create table testing(num int, addr varchar(40),
contents blob(16M),contents2 blob(16M))");
conn.commit();
// If I insert a row it will work ok.
if ("insert".equals(args[0]))
s.executeUpdate("insert into testing values (1,'addr',NULL,NULL)");
byte[] data = new byte[ 38000];
for (int i = 0; i < data.length; i++)
data[i] = 'a';
ByteArrayInputStream is = new ByteArrayInputStream( data);
ByteArrayInputStream is2 = new ByteArrayInputStream(data);
String sql = "UPDATE testing SET Contents=?, contents2=? WHERE num=1";
PreparedStatement ps = conn.prepareStatement( sql);
ps.setBinaryStream( 1, is,data.length);
ps.setBinaryStream(2, is2,data.length);
ps.executeUpdate();
ps.close();
conn.commit();
conn.close();
}
}