01 April 2007

Release of Connection Pool Lib

I have previously published an article at codeproject.com that describes the design of a connection pool. The source included with that article is not complete, but it still works! I have now taken the next step and finished the implementatin of the connection pool.

The implemenation is divided into three dynamic libraries:

database.dllcontains the abstraction layer of the pool

adoadapter.dllcontains a concrete ADO implementation of the pool

settings.dllcontains functionality to store the settings in the registry

Compared to the source included with the article at codeproject, this implementation has been enhanced further i.e. :

the connection string is now stored encrypted in the registry.

the abstraction layer has been put into its own dynamic link library. This makes it possible to encapsulate the vendor specific implementation and it becomes easier to change from one database to another.

the methods aquire() and release() are now made thread-safe.

the storing logic has been moved into a separate dynamic link library, which makes it possible to store the settings another place if a dynamic link library with the same interface is made by deriving the implementation from the abstract CPoolSettings class.

The snippet below illustrates briefly how the connection pool is used.

First time the pool is used it will store the initial size and an encrypted connection string (with default values) in the registry. The connection string that containts the default values are written in plaintext to a file named "pool-regvalues.txt", which easily can be modified and pasted into the registry.

Another (and maybe incomplete) implementation of the connection pool in C# can be found at one of my elderly posts, which can be accessed here.

4 Comments:

I have downloaded the implementation of the connection pool. when I tried to use it in a program like the snipped above and try to build it in codeblocks using GNU GCC compiler I get the following error message:||=== TestConPool, Debug ===|C:\Forex Source Code\PostgresqlDLL Dev\TestConPool\database.h|7|comdef.h: No such file or directory|C:\Forex Source Code\PostgresqlDLL Dev\TestConPool\database.h|28|error: `_variant_t' does not name a type|C:\Forex Source Code\PostgresqlDLL Dev\TestConPool\database.h|34|error: `GUID' does not name a type|C:\Forex Source Code\PostgresqlDLL Dev\TestConPool\adoadapter.h|7|warning: ignoring #pragma warning |C:\Forex Source Code\PostgresqlDLL Dev\TestConPool\adoadapter.h|19|error: `_variant_t' does not name a type|C:\Forex Source Code\PostgresqlDLL Dev\TestConPool\adoadapter.h|22|error: `_variant_t' does not name a type|C:\Forex Source Code\PostgresqlDLL Dev\TestConPool\adoadapter.h|25|error: `_ConnectionPtr' does not name a type|C:\Forex Source Code\PostgresqlDLL Dev\TestConPool\adoadapter.h|39|error: `HANDLE' does not name a type|C:\Forex Source Code\PostgresqlDLL Dev\TestConPool\main.cpp|5|warning: extra tokens at end of #import directive|C:\Forex Source Code\PostgresqlDLL Dev\TestConPool\main.cpp|5|msado15.dll: No such file or directory|||=== Build finished: 8 errors, 2 warnings ===|