DataConnector | ComponentOne
ADO.NET provider for JSON / Connection Pooling
In This Topic
    Connection Pooling
    In This Topic

    ADO.NET provider for JSON implements connection pooling to reduce the efforts of repeatedly opening and closing connections. A connection pool is a cache of database connections maintained where 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 property to false.

    The following code demonstrates the implementation of connection pooling in ADO.NET provider for JSON with the Max Pool Size key set to 20.

    C#
    Copy Code
    //With Connection Pooling: It saves your time as the connection object is already available in the pool
    string documentConStr = $"Data Model=Document;Uri='json_bookstore.json';Json Path='$.bookstore.books'; Max Pool Size = 20";

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

    C#
    Copy Code
    //Without connection Pooling
    string documentConStr = $"Data Model=Document;Uri='json_bookstore.json';Json Path='$.bookstore.books';Use Pool= false";