| java.lang.Object org.apache.derbyTesting.functionTests.tests.jdbcapi.SetQueryTimeoutTest
SetQueryTimeoutTest | public class SetQueryTimeoutTest (Code) | | Functional test for the Statement.setQueryTimeout() method.
This test consists of four parts:
1. Executes a SELECT query in 4 different threads concurrently.
The query calls a user-defined, server-side function which
delays the execution, so that it takes several seconds even
though the data volume is really low. The fetch operations
take longer time than the timeout value set. Hence, this part
tests getting timeouts from calls to ResultSet.next().
Two connections are used, two threads execute their statement
in the context of one connection, the other two threads in the
context of the other connection. Of the 4 threads, only one
executes its statement with a timeout value. This way, the test
ensures that the correct statement is affected by setQueryTimeout(),
regardless of what connection/transaction it and other statements
are executed in the context of.
2. Executes an INSERT query in multiple threads.
This part tests getting timeouts from calls to Statement.execute().
Each thread executes the query in the context of a separate
connection. There is no point in executing multiple statements
on the same connection; since only one statement per connection
executes at a time, there will be no interleaving of execution
between them (contrary to the first part of this test, where
calls to ResultSet.next() may be interleaved between the different
threads).
Half of the threads execute their statement with a timeout value set,
this is to verify that the correct statements are affected by the
timeout, while the other statements execute to completion.
3. Sets an invalid (negative) timeout. Verifies that the correct
exception is thrown.
4. Tests that the query timeout value is not forgotten after the execution
of a statement (DERBY-1692).
|
Method Summary | |
public static int | delay(int seconds, int value) | public void | go(String[] args) The actual main bulk of this test. | public static void | main(String[] args) |
delay | public static int delay(int seconds, int value) throws SQLException(Code) | | This is the user-defined function which is called from our queries
|
go | public void go(String[] args)(Code) | | The actual main bulk of this test.
Sets up the environment, prepares tables,
runs the tests, and shuts down.
|
main | public static void main(String[] args)(Code) | | Main program, makes this class invocable from the command line
|
|
|