public class PrepareStatementTest extends BaseJDBCTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
PrepareStatementTest(java.lang.String name)
Creates a new instance of PrepareStatementTest
|
Modifier and Type | Method and Description |
---|---|
private static void |
assertDataTruncation(java.lang.String[] expectedRow,
java.lang.String[] actualRow,
int index,
boolean parameter,
boolean read,
int dataSize,
int transferSize,
java.sql.SQLWarning warning)
Assert that data returned from the server was truncated, and that the
proper warning came with the result.
|
static void |
copyString(java.lang.String in,
java.lang.String[] out)
Copy a string value from
in to out[0 }. |
private void |
insertTab(java.lang.String tabName,
int numCols)
Insert 1 row with the given number of columns into the given table.
|
private void |
jira125Test_a()
First iteration of testLargeReplies test case.
|
private void |
jira125Test_b()
Second iteration of testLargeReplies test case.
|
private static java.lang.String |
makeString(int length)
Return a string of the given length.
|
private static java.lang.String |
makeString(int length,
char ch)
Return a string of the given length filled with the specified character.
|
private void |
selectFromBigTab()
Test that the table bigtab contains the expected tuples for the test
case testBigTable.
|
static junit.framework.Test |
suite()
Adds this class to the default suite.
|
void |
testAlternatingLobValuesAndNull()
This test case ensures that the bug introduced by the first patch for
Jira-815 has not been re-introduced.
|
void |
testBasicPrepare()
Test basic prepare mechanism with executeUpdate and executeQuery with
and without simple parameters.
|
void |
testBigDecimalSetObject()
Check that values are preserved when BigDecimal values
which have more than 31 digits are converted to Double
with setObject.
|
void |
testBigDecimalSetObjectWithScale()
Test BigDecimal with scale as parameter.
|
void |
testBigTable()
Test prepared statements with a large number of input parameters.
|
void |
testDerby3230()
Test fix for protocol error if splitQRYDTA occurs during DRDAConnThread.doneData()
DERBY-3230
|
void |
testDSSLength()
Test for an off-by-one bug in the splitQRYDTA processing in the Network
Server writeQRYDTA code (Jira-1454), and is related to previous bugs
614, 170, 491, and 492.
|
void |
testExcpetionWithBigParameter()
Test how the server handles re-synchronization of
the data stream when an enormous parameter value follows a failed
prepare statement.
|
void |
testInvalidTimestamp()
Test invalid Timestamp parameters.
|
void |
testLargeBatch()
Test large batch sizes for Statement.addBatch and
Statement.executeBatch.
|
void |
testLargeParameters_a()
Test two different bugs regarding the handling of large
amounts of parameter data: first, the Network Server was incorrectly
handling the desegmentation of continued DSS segments, and second,
the Network Server was using the wrong heuristic to determine whether
long string data was being flowed in-line or externalized (Jira 1533).
|
void |
testLargeParameters_b() |
void |
testLargeReplies()
Test the proper use of continuation headers for very large reply
messages, such as the SQLDARD which is returned for a prepared
statement with an enormous number of parameter markers.
|
void |
testLongColumn()
Verify that string values aren't truncated when their UTF-8 encoded
representation exceeds 32KB.
|
void |
testManyPreparedStatements()
Test creation and execution of many Prepared Statements.
|
void |
testParameterTypes()
Tests different data types for input parameters of a PreparedStatement.
|
void |
testReadBlobCloseToMaxDssLength()
Test fix for DERBY-4088 where an ArrayIndexOutOfBoundsException was
thrown by DDMReader.readBytes() when reading a BLOB value whose length
was close to the maximum length of a DSS.
|
void |
testSmallBigDecimal()
Test small (close to 0) BigDecimal parameters.
|
void |
testSplitQRYDTABlock()
Regression test for DERBY-614.
|
void |
testVariationOfSetObject()
A test case for DERBY-3046
We were running into null pointer exception if the parameter count
for PreparedStatement was 0 and the user tried doing setObject
|
void |
testVaryingClientParameterTypeBatch()
Test execution of batch update where the type of
a parameter varies for difference entries in the batch.
|
private void |
tickleDSSLength(int c2Len)
Helper method for testDSSLength test case.
|
assertCallError, assertCheckTable, assertCommitError, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertResults, assertResults, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, chattyPrepare, chattyPrepareCall, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, dumpRs, dumpRs, emptyStatementCache, executeQuery, expectCompilationError, expectCompilationError, expectExecutionError, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, goodStatement, goodUpdate, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runBareOverridable, runScript, runScript, runSQLCommands, setAutoCommit, tearDown, usingDB2Client, usingDerbyNetClient, usingEmbedded
alarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSameNullness, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, newAssertionFailedError, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemErr, setSystemOut, setSystemProperty, sleep, sleepAtLeastOneTick, traceit, vmAtLeast
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, setUp, toString
public PrepareStatementTest(java.lang.String name)
name
- name of the test.public static junit.framework.Test suite()
public void testBasicPrepare() throws java.lang.Exception
java.lang.Exception
public void testParameterTypes() throws java.lang.Exception
java.lang.Exception
public void testBigTable() throws java.lang.Exception
java.lang.Exception
private void insertTab(java.lang.String tabName, int numCols) throws java.sql.SQLException
tabName
- Table namenumCols
- Number of columns in table.java.sql.SQLException
private void selectFromBigTab() throws java.sql.SQLException
java.sql.SQLException
public void testBigDecimalSetObject() throws java.sql.SQLException
java.sql.SQLException
public void testBigDecimalSetObjectWithScale() throws java.lang.Exception
java.lang.Exception
public void testVaryingClientParameterTypeBatch() throws java.lang.Exception
java.lang.Exception
public void testSmallBigDecimal() throws java.lang.Exception
java.lang.Exception
public void testManyPreparedStatements() throws java.lang.Exception
java.lang.Exception
public void testInvalidTimestamp() throws java.lang.Exception
java.lang.Exception
public void testSplitQRYDTABlock() throws java.lang.Exception
Regression test for DERBY-614. The test consists of two parts:
Part 1: Test how the server responds when the client closes the statement in between split QRYDTA blocks. We have to cause a split QRYDTA block, which we can do by having a bunch of moderately-sized rows which mostly fill a 32K block followed by a single giant row which overflows the block. Then, we fetch some of the rows, then close the result set.
Part 2: Verifies that the server-side statement state is cleaned up when a statement is re-used. Specifically, we set up a statement which has a non-null splitQRYDTA value, then we close that statement and re-use it for a totally unrelated query. If the splitQRYDTA wasn't cleaned up properly, it comes flooding back as the response to that unrelated query, causing a protocol parsing exception on the client.
java.lang.Exception
public void testExcpetionWithBigParameter() throws java.lang.Exception
java.lang.Exception
public void testLargeReplies() throws java.lang.Exception
java.lang.Exception
private void jira125Test_a() throws java.lang.Exception
java.lang.Exception
private void jira125Test_b() throws java.lang.Exception
java.lang.Exception
public void testAlternatingLobValuesAndNull() throws java.lang.Exception
java.lang.Exception
public void testLargeBatch() throws java.lang.Exception
java.lang.Exception
public void testDSSLength() throws java.lang.Exception
java.lang.Exception
private void tickleDSSLength(int c2Len) throws java.lang.Exception
c2Len
- Length to be used for the secondjava.lang.Exception
public void testVariationOfSetObject() throws java.lang.Exception
java.lang.Exception
public void testLargeParameters_a() throws java.lang.Exception
java.lang.Exception
public void testLargeParameters_b() throws java.lang.Exception
java.lang.Exception
testLargeParameters_a()
public void testDerby3230() throws java.sql.SQLException
java.sql.SQLException
private static java.lang.String makeString(int length)
length
- Length of string to be returned.private static java.lang.String makeString(int length, char ch)
public void testReadBlobCloseToMaxDssLength() throws java.lang.Exception
java.lang.Exception
public void testLongColumn() throws java.lang.Exception
java.lang.Exception
public static void copyString(java.lang.String in, java.lang.String[] out)
in
- stored procedure input parameterout
- stored procedure output parameterprivate static void assertDataTruncation(java.lang.String[] expectedRow, java.lang.String[] actualRow, int index, boolean parameter, boolean read, int dataSize, int transferSize, java.sql.SQLWarning warning)
expectedRow
- the expected valuesactualRow
- the actual values returnedindex
- the expected column/parameter index in the warningparameter
- whether the values came from a procedure parameterread
- whether the values came from a read operationdataSize
- the expected full size of the truncated valuetransferSize
- the expected size of the value after truncationwarning
- the received warningApache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.