public class PreparedStatementTest extends BaseJDBCTestCase
suite
-method.Modifier and Type | Class and Description |
---|---|
static class |
PreparedStatementTest.PreparedStatementWrapper
This wrapper is used to expose JDBC 4.2 methods which can run on
VM rev levels lower than Java 8.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
BLOBTBL |
private static byte[] |
BYTES
Byte array passed in to the database.
|
private static java.lang.String |
CLOBTBL |
private static int |
globalKey
Key used to id data inserted into the database.
|
private int |
key
Default key to use for insertions.
|
private static java.lang.String |
LONGVARCHAR |
private java.sql.PreparedStatement |
ps
PreparedStatement object with no positional arguments.
|
private java.sql.PreparedStatement |
psFetchBlob
PreparedStatement to fetch BLOB with specified id.
|
private java.sql.PreparedStatement |
psFetchClob
PreparedStatement to fetch CLOB with specified id.
|
private java.sql.PreparedStatement |
psInsertBlob
PreparedStatement to insert a BLOB with specified id.
|
private java.sql.PreparedStatement |
psInsertClob
PreparedStatement to insert a CLOB with specified id.
|
private java.sql.PreparedStatement |
psInsertLongVarchar
PreparedStatement to insert a LONG VARCHAR with specified id.
|
private java.sql.Statement |
s |
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
PreparedStatementTest(java.lang.String name)
Create a test with the given name.
|
Modifier and Type | Method and Description |
---|---|
private void |
assertInternalDerbyIOExceptionState(java.lang.String preSQLState,
java.lang.String expectedInternal,
java.sql.SQLException sqle)
This methods is not to be used, but sometimes you have to!
|
private static junit.framework.Test |
baseSuite(java.lang.String name) |
void |
cpTestIsPoolableHintFalse()
Tests that the
isPoolable -hint works by exploiting the fact that
the client cannot prepare a statement referring to a deleted table
(unless the statement is already in the statement cache). |
void |
cpTestIsPoolableHintTrue()
Tests that the
isPoolable -hint works by exploiting the fact that
the client can prepare a statement referring to a deleted table if JDBC
statement caching is enabled and the statement is already in the cache. |
static void |
largeUpdate_jdbc4_2(java.sql.Connection conn) |
private static void |
largeUpdateTest(java.sql.Statement stmt,
PreparedStatementTest.PreparedStatementWrapper psw,
long rowCountBase) |
private static int |
requestKey()
Get next key to id inserted data with.
|
private void |
setAsciiStream(java.sql.PreparedStatement ps,
int id,
int actualLength,
int specifiedLength,
int trailingBlanks,
boolean lengthLess)
Insert data into a column with setAsciiStream.
|
private void |
setBinaryStreamOnBlob(int id,
int actualLength,
int specifiedLength,
int trailingBlanks,
boolean lengthLess)
Insert data into a Blob column with setBinaryStream.
|
void |
setUp()
Obtain a "regular" connection and PreparedStatement that the tests
can use.
|
private static junit.framework.Test |
statementCachingSuite()
Returns a suite for tests that need JDBC statement caching to be enabled.
|
static junit.framework.Test |
suite() |
void |
tearDown()
Release the resources that are used in this test
|
void |
testBlobExceptionDoesNotRollbackOtherStatements() |
void |
testExceptionPathMultiplePages_bs() |
void |
testExceptionPathOnePage_bs() |
void |
testIsNotWrapperForCallableStatement() |
void |
testIsNotWrapperForResultSet() |
void |
testIsPoolableDefault()
Tests the PreparedStatement interface method isPoolable
|
void |
testIsPoolableOnClosed()
Tests the PreparedStatement interface method isPoolable on closed
PreparedStatement
|
void |
testIsWrapperForPreparedStatement() |
void |
testIsWrapperForSelf() |
void |
testIsWrapperForStatement() |
void |
testLargeUpdate_jdbc4_2()
Test the large update methods added by JDBC 4.2.
|
void |
testSetAsciiStream()
Tests the PreparedStatement interface method setAsciiStream
|
void |
testSetAsciiStreamLengthless() |
void |
testSetAsciiStreamLengthLess1KOnClob() |
void |
testSetAsciiStreamLengthLess32KOnClob() |
void |
testSetAsciiStreamLengthLess65KOnClob() |
void |
testSetAsciiStreamLengthLessOnClobTooLong() |
void |
testSetAsciiStreamLengthLessOnClobTooLongTruncate() |
void |
testSetAsciiStreamLengthlessOnLongVarCharDontTruncate() |
void |
testSetAsciiStreamLengthlessOnLongVarCharTooLong() |
void |
testSetBinaryStream()
Tests the PreparedStatement interface method setBinaryStream
|
void |
testSetBinaryStreamLengthless() |
void |
testSetBinaryStreamLengthLess1KOnBlob() |
void |
testSetBinaryStreamLengthLess32KOnBlob() |
void |
testSetBinaryStreamLengthLess65KOnBlob() |
void |
testSetBinaryStreamLengthLessOnBlobTooLong() |
void |
testSetBlob()
Test the setBlob() method
|
void |
testSetBlobLengthless()
Insert
Blob without specifying length and read it back
for verification. |
void |
testSetCharacterStream()
Tests the PreparedStatement interface method setCharacterStream
|
void |
testSetCharacterStreamLengthless() |
void |
testSetClob()
Test the setClob() method
|
void |
testSetClobLengthless()
Insert
Clob without specifying length and read it back
for verification. |
void |
testSetNCharacterStream()
Tests the setNCharacterStream method of the PreparedStatement interface
|
void |
testSetNCharacterStreamLengthlessNotImplemented() |
void |
testSetNClob1()
Tests the setNClob method of the PreparedStatement interface
|
void |
testSetNClob2()
Tests the setNClob method of the PreparedStatement interface
|
void |
testSetNClobLengthlessNotImplemented() |
void |
testSetNString()
Tests the setNString method of the PreparedStatement interface
|
void |
testSetPoolable()
Tests the PreparedStatement interface method setPoolable
|
void |
testSetPoolableOnClosed()
Tests the PreparedStatement interface method setPoolable on a closed
PreparedStatement
|
void |
testSetRowId()
Tests the setRowId method of the PreparedStatement interface
|
void |
testSetSQLXML()
Tests the setSQLXML method of the PreparedStatement interface
|
void |
testUnwrapAsSelf() |
void |
testUnwrapCallableStatement() |
void |
testUnwrapPreparedStatement() |
void |
testUnwrapResultSet() |
void |
testUnwrapStatement() |
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, 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, toString
private static final java.lang.String BLOBTBL
private static final java.lang.String CLOBTBL
private static final java.lang.String LONGVARCHAR
private static int globalKey
private static final byte[] BYTES
private int key
private java.sql.PreparedStatement ps
private java.sql.PreparedStatement psFetchBlob
private java.sql.PreparedStatement psInsertBlob
private java.sql.PreparedStatement psFetchClob
private java.sql.PreparedStatement psInsertClob
private java.sql.PreparedStatement psInsertLongVarchar
private java.sql.Statement s
public PreparedStatementTest(java.lang.String name)
name
- name of the test.public void setUp() throws java.sql.SQLException
setUp
in class junit.framework.TestCase
java.sql.SQLException
public void tearDown() throws java.lang.Exception
tearDown
in class BaseJDBCTestCase
java.sql.SQLException
java.lang.Exception
public static junit.framework.Test suite()
private static junit.framework.Test baseSuite(java.lang.String name)
private static junit.framework.Test statementCachingSuite()
public void testSetRowId() throws java.sql.SQLException
java.sql.SQLException
- upon any failure that occurs in the
call to the method.public void testSetNString() throws java.sql.SQLException
java.sql.SQLException
- upon any failure that occurs in the
call to the method.public void testSetNCharacterStream() throws java.sql.SQLException
java.sql.SQLException
- upon any failure that occurs in the
call to the method.public void testSetNCharacterStreamLengthlessNotImplemented() throws java.sql.SQLException
java.sql.SQLException
public void testSetNClobLengthlessNotImplemented() throws java.sql.SQLException
java.sql.SQLException
public void testSetNClob1() throws java.sql.SQLException
java.sql.SQLException
- upon any failure that occurs in the
call to the method.public void testSetNClob2() throws java.sql.SQLException
java.sql.SQLException
- upon any failure that occurs in the
call to the method.public void testSetSQLXML() throws java.sql.SQLException
java.sql.SQLException
- upon any failure that occurs in the
call to the method.public void testIsWrapperForStatement() throws java.sql.SQLException
java.sql.SQLException
public void testIsWrapperForPreparedStatement() throws java.sql.SQLException
java.sql.SQLException
public void testIsNotWrapperForCallableStatement() throws java.sql.SQLException
java.sql.SQLException
public void testIsNotWrapperForResultSet() throws java.sql.SQLException
java.sql.SQLException
public void testIsWrapperForSelf() throws java.sql.SQLException
java.sql.SQLException
public void testUnwrapStatement() throws java.sql.SQLException
java.sql.SQLException
public void testUnwrapPreparedStatement() throws java.sql.SQLException
java.sql.SQLException
public void testUnwrapAsSelf() throws java.sql.SQLException
java.sql.SQLException
public void testUnwrapCallableStatement()
public void testUnwrapResultSet()
public void testSetClob() throws java.io.IOException, java.sql.SQLException
java.sql.SQLException
- if a failure occurs during the call to setClobjava.io.IOException
public void testSetClobLengthless() throws java.io.IOException, java.sql.SQLException
Clob
without specifying length and read it back
for verification.java.io.IOException
- If an IOException during the close operation on the
reader.java.sql.SQLException
- If an SQLException occurs.public void testSetBlob() throws java.io.IOException, java.sql.SQLException
java.sql.SQLException
- if a failure occurs during the call to setBlobjava.io.IOException
public void testSetBlobLengthless() throws java.io.IOException, java.sql.SQLException
Blob
without specifying length and read it back
for verification.java.io.IOException
java.sql.SQLException
public void testSetPoolable() throws java.sql.SQLException
java.sql.SQLException
public void testSetPoolableOnClosed() throws java.sql.SQLException
java.sql.SQLException
public void testIsPoolableDefault() throws java.sql.SQLException
java.sql.SQLException
public void cpTestIsPoolableHintFalse() throws java.sql.SQLException
isPoolable
-hint works by exploiting the fact that
the client cannot prepare a statement referring to a deleted table
(unless the statement is already in the statement cache).java.sql.SQLException
- if something goes wrong...public void cpTestIsPoolableHintTrue() throws java.sql.SQLException
isPoolable
-hint works by exploiting the fact that
the client can prepare a statement referring to a deleted table if JDBC
statement caching is enabled and the statement is already in the cache.java.sql.SQLException
- if something goes wrong...public void testIsPoolableOnClosed() throws java.sql.SQLException
java.sql.SQLException
public void testSetCharacterStream() throws java.lang.Exception
java.sql.SQLException
java.lang.Exception
public void testSetCharacterStreamLengthless() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSetAsciiStream() throws java.lang.Exception
java.sql.SQLException
java.lang.Exception
public void testSetAsciiStreamLengthless() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSetBinaryStream() throws java.lang.Exception
java.sql.SQLException
java.lang.Exception
public void testSetBinaryStreamLengthless() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSetBinaryStreamLengthLess1KOnBlob() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSetBinaryStreamLengthLess32KOnBlob() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSetBinaryStreamLengthLess65KOnBlob() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSetBinaryStreamLengthLessOnBlobTooLong()
public void testExceptionPathOnePage_bs() throws java.sql.SQLException
java.sql.SQLException
public void testExceptionPathMultiplePages_bs() throws java.sql.SQLException
java.sql.SQLException
public void testBlobExceptionDoesNotRollbackOtherStatements() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSetAsciiStreamLengthLess1KOnClob() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSetAsciiStreamLengthLess32KOnClob() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSetAsciiStreamLengthLess65KOnClob() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void testSetAsciiStreamLengthLessOnClobTooLong()
public void testSetAsciiStreamLengthLessOnClobTooLongTruncate() throws java.sql.SQLException
java.sql.SQLException
public void testSetAsciiStreamLengthlessOnLongVarCharTooLong()
public void testSetAsciiStreamLengthlessOnLongVarCharDontTruncate()
public void testLargeUpdate_jdbc4_2() throws java.lang.Exception
java.lang.Exception
public static void largeUpdate_jdbc4_2(java.sql.Connection conn) throws java.lang.Exception
java.lang.Exception
private static void largeUpdateTest(java.sql.Statement stmt, PreparedStatementTest.PreparedStatementWrapper psw, long rowCountBase) throws java.lang.Exception
java.lang.Exception
private void setBinaryStreamOnBlob(int id, int actualLength, int specifiedLength, int trailingBlanks, boolean lengthLess) throws java.sql.SQLException
id
- unique id for inserted rowactualLength
- the actual length of the streamspecifiedLength
- the specified length of the streamtrailingBlanks
- number of characters at the end that is blanklengthLess
- whether to use the length less overloads or notjava.sql.SQLException
private void setAsciiStream(java.sql.PreparedStatement ps, int id, int actualLength, int specifiedLength, int trailingBlanks, boolean lengthLess) throws java.sql.SQLException
id
- unique id for inserted rowactualLength
- the actual length of the streamspecifiedLength
- the specified length of the streamtrailingBlanks
- number of characters at the end that is blanklengthLess
- whether to use the length less overloads or notjava.sql.SQLException
private static int requestKey()
private void assertInternalDerbyIOExceptionState(java.lang.String preSQLState, java.lang.String expectedInternal, java.sql.SQLException sqle)
preSQLState
- the expected outer SQL stateexpectedInternal
- the expected internal SQL statesqle
- the outer SQLExceptionApache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.