Rss Feed

01 April 2007

Release of Connection Pool Lib

I have previously published an article at 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.dll
    contains the abstraction layer of the pool
  • adoadapter.dll
    contains a concrete ADO implementation of the pool
  • settings.dll
    contains 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.

-- snip --
#include "database.h"
#include "adoadapter.h"

#import "msado15.dll" rename_namespace("")
rename("EOF", "ADO_EOF") rename("BOF", "ADO_BOF")

CPoolFactory * factory = new CADOPoolFactory;
CPool * pool = factory->getPool();
CResource * res = pool->aquire();
// use the connection, i.e.
// recordset->Open("SELECT STMT",
// res->getConnectionVariant() /* we use it here */,
// adOpenDynamic, adLockOptimistic, adCmdText);
// ...
// recordset->Close()
res = NULL;
-- snip --

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.

Download C++ library

(if the link fails by left-clicking on it, then right-click and choose "Save target as..." or "Copy link address")


Anonymous Anonymous said...

thanks for your job,i cannot download
the Download C++ library of
pls check up it.

atota from china
my email is

22 February, 2009 05:38  
Blogger Unknown said...

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 ===|

05 April, 2009 09:09  
Blogger jessn said...

Gideon, it looks like you need the core Windows components. All the types that cannot be found are Windows types such as GUID, _variant_t among others.

Please check your project settings and ensure that all include- and library paths exist respectively.

06 April, 2009 14:40  
Blogger jessn said...

Atota, you can download the connection pool library from the following url:

Please note that I am currently working on a logging framework, which allow logging to different sources and adapts to the database connection lib.

Let me know if it causes you any problem.

06 April, 2009 14:48  

Post a comment

<< Home