You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any advice on how to achieve connection pooling with a jdbc.net connection? I'm using this for a web api and looking to reduce overhead of opening connections
The text was updated successfully, but these errors were encountered:
Use the Factory Pattern to provide connections that you pool. Wrap the JdbcConnections in a class that can hold a reference to the pool, that which the pool will recycle it when you finish using it in a using statement (disposable).
In the factory keep a list of wrapped-connections private JdbcConnectionWrapper[] Connections = new JdbcConnectionWrapper[POOL_SIZE];. and a list of locks private int[] Locks = new int[POOL_SIZE];.
locks[i] is 0 for free or 1 for in use. when requesting a connection loop over connections pool and check for unused connections. Interlocked.CompareExchange(ref Locks[i], 1, 0) == 0 is your friend (atomic / locking). I'd post all of my code, but I'd need approval from my boss.
also, take a moment to see my pull request for making JDBC.NET web api compatible: #29
Any advice on how to achieve connection pooling with a jdbc.net connection? I'm using this for a web api and looking to reduce overhead of opening connections
The text was updated successfully, but these errors were encountered: