public void testReadBlobCloseToMaxDssLength() throws Exception {
final int length = 32766; // max DSS length is 32767
// Create test data with the requested length
DataInputStream stream1 =
new DataInputStream(new LoopingAlphabetStream(length));
byte[] bytes = new byte[length];
stream1.readFully(bytes);
// See if the test data can be sent to the server and back with
// no errors.
PreparedStatement ps = prepareStatement("values cast(? as blob)");
ps.setBytes(1, bytes);
ResultSet rs = ps.executeQuery();
assertTrue("empty result set", rs.next());
InputStream stream2 = rs.getBinaryStream(1);
assertEquals(new LoopingAlphabetStream(length), stream2);
assertFalse("too many rows", rs.next());
rs.close();
}