Oracle Connection pooling
System.Data.OracleClient でコネクションプールを利用する
- Connection Lifetime (既定0)
- プールの作成時刻と現在時刻を比較して(秒単位)その差が設定値を超えている場合接続を破棄
- Max Pool Size (既定100)
- プールされる最大接続数
- Min Pool Size (既定0)
- プールされる最小接続数
- Pooling (既定true)
- trueに設定するとプールを利用
Timeout expired.The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
これはコネクションプールが設定上限に達した為にタイムアウトしたというエラー
- 必要に応じて Max Pool Size の調整をする
- 接続の閉じ忘れがあるかもしれない
ClearPool()メソッドなるものが気になる。
You have some ways to close the connection like:
- Implementing try-catch-finally block(and close the connection in the finally section)
- Implementing using block (This is the elegant way, it will call the dispose method automatically).
使用例
C#public void CreateOracleConnection() { string connectionString = "Data Source=Oracle8i;Integrated Security=yes"; using (OracleConnection connection = new OracleConnection(connectionString)) { connection.Open(); Console.WriteLine("ServerVersion: " + connection.ServerVersion + "\nDataSource: " + connection.DataSource); } }