> # Threading

> The JDBC driver is completely thread safe; that is, it will not fail when database requests are made on separate threads.

> ### Threading Architecture

> A JDBC driver can be based on one of the following architectures:

> - Thread impaired. The JDBC driver serializes all JDBC calls. All requests are handled one by one, without concurrent processing.
> - Thread per connection. The JDBC driver processes requests concurrently with statements that do not share the same connection; however requests on the same connection are serialized. The SequeLink for JDBC driver uses this architecture.
> - Fully threaded. All requests use the threaded model. The JDBC driver processes all requests on multiple statements concurrently.

> ### Cancelling Functions in Multithreaded Applications

> In a multithreaded application, a thread can use the cancel method to cancel a statement that is being executed by another thread. Whether the cancel method actually cancels the statement depends on the data store being accessed as shown in Table 8-2.

> - OK means that cancel can interrupt the running statement.
> - Ignored means that cancel will have no affect on the running statement.

> In both cases, the cancel method returns `SQL_SUCCESS`. If the cancel method has been called from a different thread while a request is pending, the original statement will return `SQL_ERROR` with the error message `Operation cancelled`.

> Table 8-2. Using Cancel in Multithreaded JDBC Applications
> Data Store | SQLCancel
> --- | ---
> DB2 UDB on z/OS | Ignored
> DB2 UDB on Windows | OK
> DB2 UDB on Linux/UNIX | Ignored
> Informix | OK
> Microsoft SQL Server | OK
> Oracle on Windows | Ignored
> Oracle on UNIX | OK
> Sybase | OK
> NOTE: Cancel functionality is not supported when the connection uses Secure Socket Layer (SSL) encryption.