# PooledConnection

Artifact: [androidx.room3:room3-runtime](https://developer.android.com/jetpack/androidx/releases/room3) [View Source](https://cs.android.com/search?q=file:androidx/room3/Transactor.kt+class:androidx.room3.PooledConnection) Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

*** ** * ** ***


```
public interface PooledConnection
```

<br />

Known direct subclasses [TransactionScope](https://developer.android.com/reference/androidx/room3/TransactionScope), [Transactor](https://developer.android.com/reference/androidx/room3/Transactor)

|---|---|
| `https://developer.android.com/reference/androidx/room3/TransactionScope` | A `https://developer.android.com/reference/androidx/room3/PooledConnection` with an active transaction capable of performing nested transactions. |
| `https://developer.android.com/reference/androidx/room3/Transactor` | A `https://developer.android.com/reference/androidx/room3/PooledConnection` that can perform transactions. |

*** ** * ** ***

A wrapper of `https://developer.android.com/reference/androidx/sqlite/SQLiteConnection` that belongs to a connection pool and is safe to use in a coroutine.

## Summary

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull R` | `<R extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/room3/PooledConnection#usePrepared(kotlin.String,kotlin.coroutines.SuspendFunction1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html sql, @https://developer.android.com/reference/androidx/annotation/NonNull SuspendFunction1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/SQLiteStatement, @https://developer.android.com/reference/androidx/annotation/NonNull R> block )` Prepares a new SQL statement and use it within the code `https://developer.android.com/reference/androidx/room3/PooledConnection#usePrepared(kotlin.String,kotlin.coroutines.SuspendFunction1)`. |

| ### Extension functions |
|---|---|
| `default final void` | `https://developer.android.com/reference/androidx/room3/TransactorKt.https://developer.android.com/reference/androidx/room3/PooledConnection#(androidx.room3.PooledConnection).executeSQL(kotlin.String)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room3/PooledConnection receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html sql )` Executes a single SQL statement that returns no values. |

## Public methods

### usePrepared

```
abstract @NonNull R <R extends Object> usePrepared(
    @NonNull String sql,
    @NonNull SuspendFunction1<@NonNull SQLiteStatement, @NonNull R> block
)
```

Prepares a new SQL statement and use it within the code `https://developer.android.com/reference/androidx/room3/PooledConnection#usePrepared(kotlin.String,kotlin.coroutines.SuspendFunction1)`.

Using the given `https://developer.android.com/reference/androidx/sqlite/SQLiteStatement` after `https://developer.android.com/reference/androidx/room3/PooledConnection#usePrepared(kotlin.String,kotlin.coroutines.SuspendFunction1)` completes is prohibited. The statement will also be coroutine confined, attempting to use it from another coroutine is an error.

Using a statement locks the connection it belongs to, therefore try not to do long-running computations within the `https://developer.android.com/reference/androidx/room3/PooledConnection#usePrepared(kotlin.String,kotlin.coroutines.SuspendFunction1)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html sql` | The SQL statement to prepare |
| `@https://developer.android.com/reference/androidx/annotation/NonNull SuspendFunction1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/SQLiteStatement, @https://developer.android.com/reference/androidx/annotation/NonNull R> block` | The code to use the statement |

## Extension functions

### TransactorKt.executeSQL

Artifact: [androidx.room3:room3-runtime](https://developer.android.com/jetpack/androidx/releases/room3) [View Source](https://cs.android.com/search?q=file:androidx/room3/Transactor.kt+function:executeSQL)

```
default final void TransactorKt.executeSQL(
    @NonNull PooledConnection receiver,
    @NonNull String sql
)
```

Executes a single SQL statement that returns no values.