2 using ByteFX
.Data
.Common
;
3 using System
.Collections
;
5 namespace ByteFX
.Data
.MySqlClient
8 /// Summary description for MySqlPoolManager.
10 internal sealed class MySqlPoolManager
12 private static Hashtable pools
;
14 public MySqlPoolManager()
21 private static void Initialize()
23 pools
= new Hashtable();
26 public static MySqlInternalConnection
GetConnection( MySqlConnectionString settings
)
28 // make sure the manager is initialized
29 if (MySqlPoolManager
.pools
== null)
30 MySqlPoolManager
.Initialize();
32 string text
= settings
.GetConnectionString();
34 lock( pools
.SyncRoot
)
37 if (!pools
.Contains( text
))
39 pool
= new MySqlPool( settings
);
40 pools
.Add( text
, pool
);
44 pool
= (pools
[text
] as MySqlPool
);
47 return pool
.GetConnection();
51 public static void ReleaseConnection( MySqlInternalConnection connection
)
55 string key
= connection
.Settings
.GetConnectionString();
56 MySqlPool pool
= (MySqlPool
)pools
[ key
];
58 throw new MySqlException("Pooling exception: Unable to find original pool for connection");
59 pool
.ReleaseConnection(connection
);