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, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, emptyStatementCache, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runBareOverridable, runScript, runScript, runSQLCommands, setAutoCommit, usingDB2Client, usingDerbyNetClient, usingEmbeddedalarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isJava8, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemProperty, sleep, sleepAtLeastOneTick, traceitassertEquals, 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, toStringprivate 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.TestCasejava.sql.SQLExceptionpublic void tearDown()
throws java.lang.Exception
tearDown in class BaseJDBCTestCasejava.sql.SQLExceptionjava.lang.Exceptionpublic 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.SQLExceptionpublic void testSetNClobLengthlessNotImplemented()
throws java.sql.SQLException
java.sql.SQLExceptionpublic 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.SQLExceptionpublic void testIsWrapperForPreparedStatement()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testIsNotWrapperForCallableStatement()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testIsNotWrapperForResultSet()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testIsWrapperForSelf()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testUnwrapStatement()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testUnwrapPreparedStatement()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testUnwrapAsSelf()
throws java.sql.SQLException
java.sql.SQLExceptionpublic 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.IOExceptionpublic 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.IOExceptionpublic void testSetBlobLengthless()
throws java.io.IOException,
java.sql.SQLException
Blob without specifying length and read it back
for verification.java.io.IOExceptionjava.sql.SQLExceptionpublic void testSetPoolable()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testSetPoolableOnClosed()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testIsPoolableDefault()
throws java.sql.SQLException
java.sql.SQLExceptionpublic 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.SQLExceptionpublic void testSetCharacterStream()
throws java.lang.Exception
java.sql.SQLExceptionjava.lang.Exceptionpublic void testSetCharacterStreamLengthless()
throws java.io.IOException,
java.sql.SQLException
java.io.IOExceptionjava.sql.SQLExceptionpublic void testSetAsciiStream()
throws java.lang.Exception
java.sql.SQLExceptionjava.lang.Exceptionpublic void testSetAsciiStreamLengthless()
throws java.io.IOException,
java.sql.SQLException
java.io.IOExceptionjava.sql.SQLExceptionpublic void testSetBinaryStream()
throws java.lang.Exception
java.sql.SQLExceptionjava.lang.Exceptionpublic void testSetBinaryStreamLengthless()
throws java.io.IOException,
java.sql.SQLException
java.io.IOExceptionjava.sql.SQLExceptionpublic void testSetBinaryStreamLengthLess1KOnBlob()
throws java.io.IOException,
java.sql.SQLException
java.io.IOExceptionjava.sql.SQLExceptionpublic void testSetBinaryStreamLengthLess32KOnBlob()
throws java.io.IOException,
java.sql.SQLException
java.io.IOExceptionjava.sql.SQLExceptionpublic void testSetBinaryStreamLengthLess65KOnBlob()
throws java.io.IOException,
java.sql.SQLException
java.io.IOExceptionjava.sql.SQLExceptionpublic void testSetBinaryStreamLengthLessOnBlobTooLong()
public void testExceptionPathOnePage_bs()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testExceptionPathMultiplePages_bs()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testBlobExceptionDoesNotRollbackOtherStatements()
throws java.io.IOException,
java.sql.SQLException
java.io.IOExceptionjava.sql.SQLExceptionpublic void testSetAsciiStreamLengthLess1KOnClob()
throws java.io.IOException,
java.sql.SQLException
java.io.IOExceptionjava.sql.SQLExceptionpublic void testSetAsciiStreamLengthLess32KOnClob()
throws java.io.IOException,
java.sql.SQLException
java.io.IOExceptionjava.sql.SQLExceptionpublic void testSetAsciiStreamLengthLess65KOnClob()
throws java.io.IOException,
java.sql.SQLException
java.io.IOExceptionjava.sql.SQLExceptionpublic void testSetAsciiStreamLengthLessOnClobTooLong()
public void testSetAsciiStreamLengthLessOnClobTooLongTruncate()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testSetAsciiStreamLengthlessOnLongVarCharTooLong()
public void testSetAsciiStreamLengthlessOnLongVarCharDontTruncate()
public void testLargeUpdate_jdbc4_2()
throws java.lang.Exception
java.lang.Exceptionpublic static void largeUpdate_jdbc4_2(java.sql.Connection conn)
throws java.lang.Exception
java.lang.Exceptionprivate static void largeUpdateTest(java.sql.Statement stmt,
PreparedStatementTest.PreparedStatementWrapper psw,
long rowCountBase)
throws java.lang.Exception
java.lang.Exceptionprivate 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.SQLExceptionprivate 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.SQLExceptionprivate 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.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.