Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - Programming » .NET application programming » SQL Anywhere .NET Data Provider » .NET database connection examples


Connection pooling

The SQL Anywhere .NET Data Provider supports native .NET connection pooling. Connection pooling allows your application to reuse existing connections by saving the connection handle to a pool so it can be reused, rather than repeatedly creating a new connection to the database. Connection pooling is enabled by default.

Connection pooling is enabled and disabled using the Pooling option. The maximum pool size is set in your connection string using the Max Pool Size option. The minimum or initial pool size is set in your connection string using the Min Pool Size option. The default maximum pool size is 100, while the default minimum pool size is 0.

"Data Source=SQL Anywhere 16 Demo;Pooling=true;Max Pool Size=50;Min Pool Size=5"

When your application first attempts to connect to the database, it checks the pool for an existing connection that uses the same connection parameters you have specified. If a matching connection is found, that connection is used. Otherwise, a new connection is used. When you disconnect, the connection is returned to the pool so that it can be reused.

The SQL Anywhere database server also supports connection pooling. This feature is controlled using the ConnectionPool (CPOOL) connection parameter. However, the SQL Anywhere .NET Data Provider does not use this server feature and disables it (CPOOL=NO). All connection pooling is done in the .NET client application instead (client-side connection pooling).