Permalink
Browse files

"Automated commit at 2014-03-07 16:54:53 UTC by middleman-deploy 0.1.4"

  • Loading branch information...
1 parent 49e01cc commit 6c3b6f9c021fa68a9e46b6057edb1508bba455b2 @seratch seratch committed Mar 7, 2014
@@ -150,6 +150,28 @@ <h3 id="toc_4">Replacing ConnectionPool on Runtime</h3>
<hr/>
+<p>You can replace ConnectionPool settings safely on runtime. </p>
+
+<p>The old pool won&rsquo;t be abandoned until all the borrwoed connections are closed.</p>
+<pre class="highlight java"><span class="n">def</span> <span class="n">doSomething</span> <span class="o">=</span> <span class="o">{</span>
+ <span class="n">ConnectionPool</span><span class="o">.</span><span class="na">singleton</span><span class="o">(</span><span class="s">&quot;jdbc:h2:mem:db1&quot;</span><span class="o">,</span> <span class="s">&quot;user&quot;</span><span class="o">,</span> <span class="s">&quot;pass&quot;</span><span class="o">)</span>
+ <span class="n">DB</span> <span class="n">localTx</span> <span class="o">{</span> <span class="n">implicit</span> <span class="n">s</span> <span class="o">=&gt;</span>
+ <span class="c1">// long transaction...</span>
+
+ <span class="c1">// overwrite singleton CP</span>
+ <span class="n">ConnectionPool</span><span class="o">.</span><span class="na">singleton</span><span class="o">(</span><span class="s">&quot;jdbc:h2:mem:db2&quot;</span><span class="o">,</span> <span class="s">&quot;user&quot;</span><span class="o">,</span> <span class="s">&quot;pass&quot;</span><span class="o">)</span>
+
+ <span class="c1">// db1 connection pool is still available until this trancation is commited.</span>
+ <span class="c1">// Newly borrowed connections will access db2.</span>
+ <span class="o">}</span>
+<span class="o">}</span>
+</pre>
+<hr/>
+
+<h3 id="toc_5">Using Another ConnectionPool Implementation</h3>
+
+<hr/>
+
<p>If you want to use another one which is not Commons DBCP as the connection provider, You can also specify your own <code>ConnectionPoolFactory</code> as follows:</p>
<pre class="highlight java"><span class="cm">/**
* c3p0 Connection Pool Factory
Oops, something went wrong. Retry.

0 comments on commit 6c3b6f9

Please sign in to comment.