use of org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetStream in project derby by apache.
the class PreparedStatementTest method testSetBinaryStreamLengthLess65KOnBlob.
public void testSetBinaryStreamLengthLess65KOnBlob() throws IOException, SQLException {
int length = 65 * 1024;
setBinaryStreamOnBlob(key, length, -1, 0, true);
psFetchBlob.setInt(1, key);
ResultSet rs = psFetchBlob.executeQuery();
assertTrue("Empty resultset", rs.next());
LoopingAlphabetStream s1 = new LoopingAlphabetStream(length);
assertEquals(new LoopingAlphabetStream(length), rs.getBinaryStream(1));
assertFalse("Resultset should have been exhausted", rs.next());
rs.close();
}
use of org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetStream in project derby by apache.
the class PreparedStatementTest method testSetAsciiStreamLengthLess32KOnClob.
public void testSetAsciiStreamLengthLess32KOnClob() throws IOException, SQLException {
int length = 32 * 1024;
setAsciiStream(psInsertClob, key, length, -1, 0, true);
psFetchClob.setInt(1, key);
ResultSet rs = psFetchClob.executeQuery();
assertTrue("Empty resultset", rs.next());
assertEquals(new LoopingAlphabetStream(length), rs.getAsciiStream(1));
assertFalse("Resultset should have been exhausted", rs.next());
rs.close();
}
use of org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetStream in project derby by apache.
the class PreparedStatementTest method testSetAsciiStreamLengthLess65KOnClob.
public void testSetAsciiStreamLengthLess65KOnClob() throws IOException, SQLException {
int length = 65 * 1024;
setAsciiStream(psInsertClob, key, length, -1, 0, true);
psFetchClob.setInt(1, key);
ResultSet rs = psFetchClob.executeQuery();
assertTrue("Empty resultset", rs.next());
assertEquals(new LoopingAlphabetStream(length), rs.getAsciiStream(1));
assertFalse("Resultset should have been exhausted", rs.next());
rs.close();
}
use of org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetStream in project derby by apache.
the class PreparedStatementTest method testSetAsciiStreamLengthLess1KOnClob.
public void testSetAsciiStreamLengthLess1KOnClob() throws IOException, SQLException {
int length = 1 * 1024;
setAsciiStream(psInsertClob, key, length, -1, 0, true);
psFetchClob.setInt(1, key);
ResultSet rs = psFetchClob.executeQuery();
assertTrue("Empty resultset", rs.next());
assertEquals(new LoopingAlphabetStream(length), rs.getAsciiStream(1));
assertFalse("Resultset should have been exhausted", rs.next());
rs.close();
}
use of org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetStream in project derby by apache.
the class PreparedStatementTest method setAsciiStream.
/**
* Insert data into a column with setAsciiStream.
* The prepared statement passed must have two positional parameters;
* one int and one more. Depending on the last parameter, the execute
* might succeed or it might fail. This is intended behavior, and should
* be handled by the caller. For instance, calling this method on an
* INT-column would fail, calling it on a CLOB-column would succeed.
*
* @param id unique id for inserted row
* @param actualLength the actual length of the stream
* @param specifiedLength the specified length of the stream
* @param trailingBlanks number of characters at the end that is blank
* @param lengthLess whether to use the length less overloads or not
*/
private void setAsciiStream(PreparedStatement ps, int id, int actualLength, int specifiedLength, int trailingBlanks, boolean lengthLess) throws SQLException {
ps.setInt(1, id);
if (lengthLess) {
ps.setAsciiStream(2, new LoopingAlphabetStream(actualLength, trailingBlanks));
} else {
ps.setAsciiStream(2, new LoopingAlphabetStream(actualLength, trailingBlanks), specifiedLength);
}
assertEquals("Insert with setAsciiStream failed", 1, ps.executeUpdate());
}
Aggregations