Skip to content

Commit 4474c0d

Browse files
author
Mike Doerfler
committed
Removed ConnectionPool from ConnectionProvider and settings
for PreparedStatementCache. SVN: trunk@934
1 parent 5351d50 commit 4474c0d

File tree

3 files changed

+8
-66
lines changed

3 files changed

+8
-66
lines changed

src/NHibernate/Cfg/Environment.cs

+6
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,16 @@ public class Environment
5151
// MikeD added these while synching up SessionFactoryImpl. Not sure if they have any ado.net
5252
// equivalents - we can probably remove these and remove the SessionFactoryImpl code that
5353
// uses them.
54+
[Obsolete("Removing ConnectionPool from NH")]
5455
public const string PoolSize = "hibernate.connection.pool_size";
5556
public const string StatementBatchSize = "hibernate.jdbc.batch_size";
5657
public const string StatementFetchSize = "hibernate.jdbc.fetch_size";
5758
public const string UseScrollableResultSet = "hibernate.jdbc.use_scrollable_resultset";
59+
60+
// going to remove this - the DataProvider should implement their own IDbCommand
61+
// caching, not NHibernate
62+
[Obsolete("Removing StatementCache from NH")]
63+
public const string StatementCacheSize = "hibernate.statement_cache.size";
5864

5965
static Environment()
6066
{

src/NHibernate/Connection/ConnectionProvider.cs

-13
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public abstract class ConnectionProvider : IConnectionProvider, IDisposable
1414
{
1515
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(ConnectionProvider));
1616
private string connString = null;
17-
private int poolSize;
1817
protected IDriver driver = null;
1918

2019
public virtual void CloseConnection(IDbConnection conn)
@@ -39,13 +38,6 @@ public virtual void Configure(IDictionary settings)
3938
{
4039
log.Info( "Configuring ConnectionProvider" );
4140

42-
// default the poolSize to 0 if no setting was made because most of the .net DataProvider
43-
// do their own connection pooling. This would be useful to change to some higher number
44-
// if the .net DataProvider did not provide their own connection pooling. I don't know of
45-
// any instances of this yet.
46-
poolSize = PropertiesHelper.GetInt32( Cfg.Environment.PoolSize, settings, 0 );
47-
log.Info( "NHibernate connection pool size: " + poolSize );
48-
4941
connString = settings[ Cfg.Environment.ConnectionString ] as string;
5042
if (connString==null)
5143
{
@@ -86,11 +78,6 @@ protected virtual string ConnectionString
8678
get { return connString;}
8779
}
8880

89-
protected virtual int PoolSize
90-
{
91-
get { return poolSize; }
92-
}
93-
9481
public IDriver Driver
9582
{
9683
get {return driver;}

src/NHibernate/Connection/DriverConnectionProvider.cs

+2-53
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,17 @@ namespace NHibernate.Connection
99
/// <summary>
1010
/// A ConnectionProvider that uses an IDriver to create connections.
1111
/// </summary>
12-
/// <remarks>
13-
/// This IConnectionProvider implements a rudimentary connection pool.
14-
/// </remarks>
1512
public class DriverConnectionProvider : ConnectionProvider
1613
{
1714
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(DriverConnectionProvider));
18-
private static object poolLock = new object();
19-
private readonly ArrayList pool = new ArrayList();
2015

21-
private int checkedOut = 0;
22-
2316
public DriverConnectionProvider()
2417
{
2518
}
2619

2720

2821
public override IDbConnection GetConnection()
2922
{
30-
if(log.IsDebugEnabled) log.Debug("total checked-out connections: " + checkedOut);
31-
32-
lock(poolLock)
33-
{
34-
if( pool.Count > 0 )
35-
{
36-
int last = pool.Count - 1;
37-
if(log.IsDebugEnabled)
38-
{
39-
log.Debug("using pooled connection, pool size: " + last);
40-
checkedOut++;
41-
}
42-
43-
IDbConnection conn = (IDbConnection)pool[last];
44-
pool.RemoveAt(last);
45-
return conn;
46-
}
47-
}
48-
4923
log.Debug("Obtaining IDbConnection from Driver");
5024
try
5125
{
@@ -68,38 +42,13 @@ public override bool IsStatementCache
6842
public override void Close()
6943
{
7044
log.Info("cleaning up connection pool");
71-
72-
for(int i = 0; i < pool.Count; i++)
73-
{
74-
try
75-
{
76-
((IDbConnection)pool[i]).Close();
77-
}
78-
catch(Exception e)
79-
{
80-
log.Warn("problem closing pooled connection", e);
81-
}
82-
}
83-
84-
pool.Clear();
8545
}
8646

8747
public override void CloseConnection(IDbConnection conn)
8848
{
89-
if(log.IsDebugEnabled) checkedOut--;
90-
91-
lock(poolLock)
92-
{
93-
int currentSize = pool.Count;
94-
if( currentSize < PoolSize )
95-
{
96-
if(log.IsDebugEnabled) log.Debug("returning connection to pool, pool size: " + (currentSize + 1) );
97-
pool.Add(conn);
98-
return;
99-
}
100-
}
101-
10249
base.CloseConnection(conn);
50+
//TODO: make sure I want to do this - pretty sure I do because of Oracle problems.
51+
conn.Dispose();
10352
}
10453

10554

0 commit comments

Comments
 (0)