# Connection Pooling

## Content



ADO.NET provider for QuickBooks Online implements connection pooling to reduce the efforts of repeatedly opening and closing connections. A connection pool is a cache of database connections maintained where the user can reuse existing active connections with the same connection string instead of creating new connections when a request is made to the database.

Connection pools are used to enhance the performance of executing commands on a database. The provider supports pooling, by default with the pool size set to 100. However, pooling can be disabled by setting the [UsePool](/componentone/api/services/online-dataconnector/dotnet-standard-api/C1.DataConnector/C1.DataConnector.C1ConnectionStringBuilder.UsePool.html) property to false.

The following code demonstrates the implementation of connection pooling in ADO.NET provider for QuickBooks Online.

```csharp
// With Connection Pooling: It saves time by reusing existing connections from the pool            Console.WriteLine("Estabilishing connection setting Pooling to True");
Console.WriteLine("Estabilishing connection setting Pooling to True");
for (int i = 0; i < 1000; i++)
{
    C1QuickBooksOnlineConnection conn = new C1QuickBooksOnlineConnection($@"{connectionString};Use Pool=true;");
    conn.Open();//Soft connections are build
    //Perform Your Operation  
    conn.Close();//Connection is returned to the connection pool
}
Console.WriteLine("Connections established and closed !!! ");
```

The following example demonstrates how to disable connection pooling by setting the "Use Pool" property to false in the connection string.

```csharp
//Without Connection Pooling
Console.WriteLine("Estabilishing connection setting Pooling to False");
for (int i = 0; i < 1000; i++)
{
    C1QuickBooksOnlineConnection conn = new C1QuickBooksOnlineConnection($@"{connectionString};Use Pool=false;"); //By default pooling is true
    conn.Open();//A new connection is created each time 
    //Perform Your Operation  
    conn.Close();//Connection object moved to garbage collection
}
Console.WriteLine("Connections established and closed !!! ");    
```