File: classzdb_1_1ConnectionPool.html

package info (click to toggle)
libzdb 3.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,600 kB
  • sloc: javascript: 7,158; ansic: 6,413; sh: 3,993; cpp: 582; makefile: 114; xml: 59; lex: 35
file content (822 lines) | stat: -rw-r--r-- 56,402 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>ConnectionPool</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="libzdb.css">
</head><body>
<a href="" class="back" onclick="history.back();return false;">⬅</a>
<!-- Generated by Doxygen 1.11.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacezdb.html">zdb</a></li><li class="navelem"><a class="el" href="classzdb_1_1ConnectionPool.html">ConnectionPool</a></li>  </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle"><div class="title">ConnectionPool</div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Represents a database connection pool. </p>
<p>A <a class="el" href="classzdb_1_1ConnectionPool.html" title="Represents a database connection pool.">ConnectionPool</a> can be used to obtain connections to a database and execute statements. This class opens a number of database connections and allows callers to obtain and use a database connection in a reentrant manner. Applications can instantiate as many <a class="el" href="classzdb_1_1ConnectionPool.html" title="Represents a database connection pool.">ConnectionPool</a> objects as needed and against as many different database systems as needed.</p>
<h2><a class="anchor" id="autotoc_md55"></a>
Connection URL:</h2>
<p>The <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> given to a <a class="el" href="classzdb_1_1Connection.html" title="Represents a connection to a SQL database system.">Connection</a> Pool at creation time specifies a database connection in the standard <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> format:</p>
<div class="fragment"><div class="line">database:<span class="comment">//[user:password@][host][:port]/database[?propertyName1][=propertyValue1][&amp;propertyName2][=propertyValue2]...</span></div>
</div><!-- fragment --><p>The property names <code>user</code> and <code>password</code> are always recognized and specify how to log in to the database. Other properties depend on the database server in question. Username and password can alternatively be specified in the auth-part of the <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a>. If port number is omitted, the default port number for the database server is used.</p>
<h3><a class="anchor" id="autotoc_md56"></a>
MySQL:</h3>
<p>Example <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> for MySQL: </p><div class="fragment"><div class="line">mysql:<span class="comment">//localhost:3306/test?user=root&amp;password=swordfish</span></div>
</div><!-- fragment --><p> Or using the auth-part of the <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a>: </p><div class="fragment"><div class="line">mysql:<span class="comment">//root:swordfish@localhost:3306/test</span></div>
</div><!-- fragment --><p> See <a href="mysqloptions.html">mysql options</a> for all properties that can be set for a mysql connection <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a>.</p>
<h3><a class="anchor" id="autotoc_md57"></a>
SQLite:</h3>
<p>For SQLite, the <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> should specify a database file. SQLite uses <a href="http://sqlite.org/pragma.html">pragma commands</a> for performance tuning and other special purpose database commands. Pragma syntax in the form <code>name=value</code> can be added as properties to the <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a>. In addition to pragmas, the following properties are supported:</p>
<ul>
<li><code>serialized=true</code> - Make SQLite switch to serialized mode if value is true, otherwise multi-thread mode is used (the default).</li>
<li><code>shared-cache=true</code> - Make SQLite use shared-cache if value is true. Using shared cache can significantly reduce database lock errors in some scenarios where two or more connections might write to the database. It is also recommended to build libsqlite and libzdb with unlock notify.</li>
</ul>
<p>Example <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> for SQLite (with recommended pragmas): </p><div class="fragment"><div class="line">sqlite:<span class="comment">///var/sqlite/test.db?synchronous=normal&amp;foreign_keys=on&amp;journal_mode=wal&amp;temp_store=memory</span></div>
</div><!-- fragment --><h3><a class="anchor" id="autotoc_md58"></a>
PostgreSQL:</h3>
<p>Example <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> for PostgreSQL: </p><div class="fragment"><div class="line">postgresql:<span class="comment">//localhost:5432/test?user=root&amp;password=swordfish</span></div>
</div><!-- fragment --><p> Or using the auth-part and SSL: </p><div class="fragment"><div class="line">postgresql:<span class="comment">//root:swordfish@localhost/test?use-ssl=true</span></div>
</div><!-- fragment --><p> See <a href="postgresoptions.html">postgresql options</a> for all properties that can be set for a postgresql connection <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a>.</p>
<h3><a class="anchor" id="autotoc_md59"></a>
Oracle:</h3>
<p>Example <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> for Oracle: </p><div class="fragment"><div class="line">oracle:<span class="comment">//localhost:1521/servicename?user=scott&amp;password=tiger</span></div>
</div><!-- fragment --><p> Or using the auth-part and SYSDBA role: </p><div class="fragment"><div class="line">oracle:<span class="comment">//sys:password@localhost:1521/servicename?sysdba=true</span></div>
</div><!-- fragment --><p> See <a href="oracleoptions.html">oracle options</a> for all properties that can be set for an oracle connection <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a>.</p>
<h2><a class="anchor" id="autotoc_md60"></a>
Pool Management:</h2>
<p>The pool is designed to dynamically manage the number of active connections based on usage patterns. A <code>reaper</code> thread is automatically started when the pool is initialized, performing two functions:</p>
<ol type="1">
<li>Sweep through the pool at regular intervals (default every 60 seconds) to close connections that have been inactive for a specified time (default 90 seconds).</li>
<li>Perform periodic validation (ping test) on idle connections to ensure they remain valid and responsive.</li>
</ol>
<h2><a class="anchor" id="autotoc_md61"></a>
Realtime inspection:</h2>
<p>Three methods can be used to inspect the pool at runtime. The method <a class="el" href="#a80503477ad0a25944691f325362c12bc" title="Gets the current number of connections in the pool.">size()</a> returns the number of connections in the pool, that is, both active and inactive connections. The method <a class="el" href="#af7b327acf6e895fd4fc85138bf88db66" title="Gets the number of active connections in the pool.">active()</a> returns the number of active connections, i.e., those connections in current use by your application. The method <a class="el" href="#abf62facb0768c6757b21a1cb30f4a96d" title="Checks if the pool is full.">isFull()</a> can be used to check if the pool is full and unable to return a connection.</p>
<h2><a class="anchor" id="autotoc_md62"></a>
Example Usage:</h2>
<div class="fragment"><div class="line"><a class="code hl_class" href="classzdb_1_1ConnectionPool.html">ConnectionPool</a> pool(<span class="stringliteral">&quot;mysql://localhost/test?user=root&amp;password=swordfish&quot;</span>);</div>
<div class="line">pool.start();</div>
<div class="line"><span class="comment">// ...</span></div>
<div class="line"><a class="code hl_class" href="classzdb_1_1Connection.html">Connection</a> con = pool.getConnection();</div>
<div class="line"><a class="code hl_class" href="classzdb_1_1ResultSet.html">ResultSet</a> result = con.<a class="code hl_function" href="classzdb_1_1Connection.html#af68e46ae0740c0b7db284465656a6b45">executeQuery</a>(<span class="stringliteral">&quot;SELECT id, name, photo FROM employee WHERE salary &gt; ?&quot;</span>, 50000);</div>
<div class="line"><span class="keywordflow">while</span> (result.<a class="code hl_function" href="classzdb_1_1ResultSet.html#a80870c233d0237e3588a2d6f8d176916">next</a>()) {</div>
<div class="line">    <span class="keywordtype">int</span> <span class="keywordtype">id</span> = result.<a class="code hl_function" href="classzdb_1_1ResultSet.html#a2e7dde031277c762bd5112487b2fad52">getInt</a>(<span class="stringliteral">&quot;id&quot;</span>);</div>
<div class="line">    <span class="keyword">auto</span> name = result.<a class="code hl_function" href="classzdb_1_1ResultSet.html#ac00f123b0b60a08479a813b7d569a15a">getString</a>(<span class="stringliteral">&quot;name&quot;</span>);</div>
<div class="line">    <span class="keyword">auto</span> photo = result.<a class="code hl_function" href="classzdb_1_1ResultSet.html#ae213bd0278eb588c50988aaea9de8dc1">getBlob</a>(<span class="stringliteral">&quot;photo&quot;</span>);</div>
<div class="line">    <span class="comment">// Process data...</span></div>
<div class="line">}</div>
<div class="ttc" id="aclasszdb_1_1ConnectionPool_html"><div class="ttname"><a href="classzdb_1_1ConnectionPool.html">zdb::ConnectionPool</a></div><div class="ttdoc">Represents a database connection pool.</div><div class="ttdef"><b>Definition</b> zdbpp.h:1794</div></div>
<div class="ttc" id="aclasszdb_1_1Connection_html"><div class="ttname"><a href="classzdb_1_1Connection.html">zdb::Connection</a></div><div class="ttdoc">Represents a connection to a SQL database system.</div><div class="ttdef"><b>Definition</b> zdbpp.h:1331</div></div>
<div class="ttc" id="aclasszdb_1_1Connection_html_af68e46ae0740c0b7db284465656a6b45"><div class="ttname"><a href="classzdb_1_1Connection.html#af68e46ae0740c0b7db284465656a6b45">zdb::Connection::executeQuery</a></div><div class="ttdeci">ResultSet executeQuery(const std::string &amp;sql, Args &amp;&amp;... args)</div><div class="ttdoc">Executes a SQL query and returns a ResultSet.</div><div class="ttdef"><b>Definition</b> zdbpp.h:1584</div></div>
<div class="ttc" id="aclasszdb_1_1ResultSet_html"><div class="ttname"><a href="classzdb_1_1ResultSet.html">zdb::ResultSet</a></div><div class="ttdoc">Represents a database result set.</div><div class="ttdef"><b>Definition</b> zdbpp.h:588</div></div>
<div class="ttc" id="aclasszdb_1_1ResultSet_html_a2e7dde031277c762bd5112487b2fad52"><div class="ttname"><a href="classzdb_1_1ResultSet.html#a2e7dde031277c762bd5112487b2fad52">zdb::ResultSet::getInt</a></div><div class="ttdeci">int getInt(int columnIndex)</div><div class="ttdoc">Gets the designated column's value as an int.</div><div class="ttdef"><b>Definition</b> zdbpp.h:729</div></div>
<div class="ttc" id="aclasszdb_1_1ResultSet_html_a80870c233d0237e3588a2d6f8d176916"><div class="ttname"><a href="classzdb_1_1ResultSet.html#a80870c233d0237e3588a2d6f8d176916">zdb::ResultSet::next</a></div><div class="ttdeci">bool next()</div><div class="ttdoc">Moves the cursor to the next row.</div><div class="ttdef"><b>Definition</b> zdbpp.h:675</div></div>
<div class="ttc" id="aclasszdb_1_1ResultSet_html_ac00f123b0b60a08479a813b7d569a15a"><div class="ttname"><a href="classzdb_1_1ResultSet.html#ac00f123b0b60a08479a813b7d569a15a">zdb::ResultSet::getString</a></div><div class="ttdeci">std::optional&lt; std::string_view &gt; getString(int columnIndex)</div><div class="ttdoc">Gets the designated column's value as a string.</div><div class="ttdef"><b>Definition</b> zdbpp.h:705</div></div>
<div class="ttc" id="aclasszdb_1_1ResultSet_html_ae213bd0278eb588c50988aaea9de8dc1"><div class="ttname"><a href="classzdb_1_1ResultSet.html#ae213bd0278eb588c50988aaea9de8dc1">zdb::ResultSet::getBlob</a></div><div class="ttdeci">std::optional&lt; std::span&lt; const std::byte &gt; &gt; getBlob(int columnIndex)</div><div class="ttdoc">Gets the designated column's value as a byte span.</div><div class="ttdef"><b>Definition</b> zdbpp.h:793</div></div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>This <a class="el" href="classzdb_1_1ConnectionPool.html" title="Represents a database connection pool.">ConnectionPool</a> is thread-safe.</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>A <a class="el" href="classzdb_1_1ConnectionPool.html" title="Represents a database connection pool.">ConnectionPool</a> is neither copyable nor movable. It is designed to be a long-lived object that manages database connections throughout the lifetime of your application. Typically, you would instantiate one or more <a class="el" href="classzdb_1_1ConnectionPool.html" title="Represents a database connection pool.">ConnectionPool</a> objects as part of a resource management class or in the global scope of your application. </dd></dl>
</div>
<p>Represents a database connection pool.  
 <a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ad00f5ab1a002c93b5fbf94f751513dad" id="r_ad00f5ab1a002c93b5fbf94f751513dad"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ad00f5ab1a002c93b5fbf94f751513dad">ConnectionPool</a> (const std::string &amp;url)</td></tr>
<tr class="memdesc:ad00f5ab1a002c93b5fbf94f751513dad"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a <a class="el" href="classzdb_1_1ConnectionPool.html" title="Represents a database connection pool.">ConnectionPool</a> with the given <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> string.  <br /></td></tr>
<tr class="separator:ad00f5ab1a002c93b5fbf94f751513dad"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa1765f7d950e6bc31f74222d29b7b809" id="r_aa1765f7d950e6bc31f74222d29b7b809"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa1765f7d950e6bc31f74222d29b7b809">ConnectionPool</a> (<a class="el" href="classzdb_1_1URL.html">URL</a> &amp;&amp;url)</td></tr>
<tr class="memdesc:aa1765f7d950e6bc31f74222d29b7b809"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a <a class="el" href="classzdb_1_1ConnectionPool.html" title="Represents a database connection pool.">ConnectionPool</a> with a <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> object.  <br /></td></tr>
<tr class="separator:aa1765f7d950e6bc31f74222d29b7b809"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a80503477ad0a25944691f325362c12bc" id="r_a80503477ad0a25944691f325362c12bc"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a80503477ad0a25944691f325362c12bc">size</a> () noexcept</td></tr>
<tr class="memdesc:a80503477ad0a25944691f325362c12bc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets the current number of connections in the pool.  <br /></td></tr>
<tr class="separator:a80503477ad0a25944691f325362c12bc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af7b327acf6e895fd4fc85138bf88db66" id="r_af7b327acf6e895fd4fc85138bf88db66"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#af7b327acf6e895fd4fc85138bf88db66">active</a> () noexcept</td></tr>
<tr class="memdesc:af7b327acf6e895fd4fc85138bf88db66"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets the number of active connections in the pool.  <br /></td></tr>
<tr class="separator:af7b327acf6e895fd4fc85138bf88db66"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abf62facb0768c6757b21a1cb30f4a96d" id="r_abf62facb0768c6757b21a1cb30f4a96d"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#abf62facb0768c6757b21a1cb30f4a96d">isFull</a> () noexcept</td></tr>
<tr class="memdesc:abf62facb0768c6757b21a1cb30f4a96d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks if the pool is full.  <br /></td></tr>
<tr class="separator:abf62facb0768c6757b21a1cb30f4a96d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a60de64d75454385b23995437f1d72669" id="r_a60de64d75454385b23995437f1d72669"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a60de64d75454385b23995437f1d72669">start</a> ()</td></tr>
<tr class="memdesc:a60de64d75454385b23995437f1d72669"><td class="mdescLeft">&#160;</td><td class="mdescRight">Prepares the pool for active use.  <br /></td></tr>
<tr class="separator:a60de64d75454385b23995437f1d72669"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8c528baf37154d347366083f0f816846" id="r_a8c528baf37154d347366083f0f816846"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a8c528baf37154d347366083f0f816846">stop</a> ()</td></tr>
<tr class="memdesc:a8c528baf37154d347366083f0f816846"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gracefully terminates the pool.  <br /></td></tr>
<tr class="separator:a8c528baf37154d347366083f0f816846"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abe00cdf87aed55bbe5ef191c248b62b1" id="r_abe00cdf87aed55bbe5ef191c248b62b1"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classzdb_1_1Connection.html">Connection</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#abe00cdf87aed55bbe5ef191c248b62b1">getConnection</a> ()</td></tr>
<tr class="memdesc:abe00cdf87aed55bbe5ef191c248b62b1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets a connection from the pool.  <br /></td></tr>
<tr class="separator:abe00cdf87aed55bbe5ef191c248b62b1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1265c915e394316c05914d36138f552a" id="r_a1265c915e394316c05914d36138f552a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a1265c915e394316c05914d36138f552a">returnConnection</a> (<a class="el" href="classzdb_1_1Connection.html">Connection</a> &amp;con) noexcept</td></tr>
<tr class="memdesc:a1265c915e394316c05914d36138f552a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a connection to the pool.  <br /></td></tr>
<tr class="separator:a1265c915e394316c05914d36138f552a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a056cc693636467ed50b502fc2e841ef9" id="r_a056cc693636467ed50b502fc2e841ef9"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a056cc693636467ed50b502fc2e841ef9">reapConnections</a> () noexcept</td></tr>
<tr class="memdesc:a056cc693636467ed50b502fc2e841ef9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reaps inactive connections in the pool.  <br /></td></tr>
<tr class="separator:a056cc693636467ed50b502fc2e841ef9"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader">Properties</h2></td></tr>
<tr class="memitem:aa8c093fe9d24e17623e90f2d448f3cd6" id="r_aa8c093fe9d24e17623e90f2d448f3cd6"><td class="memItemLeft" align="right" valign="top">using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa8c093fe9d24e17623e90f2d448f3cd6">AbortHandler</a> = std::function&lt;void(std::string_view)&gt;</td></tr>
<tr class="separator:aa8c093fe9d24e17623e90f2d448f3cd6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac260bbfdf88bc970fcd8ce49f4ee1fd2" id="r_ac260bbfdf88bc970fcd8ce49f4ee1fd2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="ConnectionPool_8h.html#a6815bc519a92779e1565e92c0843eb23">CONNECTIONPOOL_TYPE</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ac260bbfdf88bc970fcd8ce49f4ee1fd2">getType</a> () const noexcept</td></tr>
<tr class="memdesc:ac260bbfdf88bc970fcd8ce49f4ee1fd2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Retrieves the database type for this <a class="el" href="classzdb_1_1ConnectionPool.html" title="Represents a database connection pool.">ConnectionPool</a>.  <br /></td></tr>
<tr class="separator:ac260bbfdf88bc970fcd8ce49f4ee1fd2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aff2fd69abe174f77bec9a7ed7812c52f" id="r_aff2fd69abe174f77bec9a7ed7812c52f"><td class="memItemLeft" align="right" valign="top">const <a class="el" href="classzdb_1_1URL.html">URL</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aff2fd69abe174f77bec9a7ed7812c52f">getURL</a> () const noexcept</td></tr>
<tr class="memdesc:aff2fd69abe174f77bec9a7ed7812c52f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets the <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> of the connection pool.  <br /></td></tr>
<tr class="separator:aff2fd69abe174f77bec9a7ed7812c52f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6c009b7305be563f672a42cc27a5d1a5" id="r_a6c009b7305be563f672a42cc27a5d1a5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a6c009b7305be563f672a42cc27a5d1a5">setInitialConnections</a> (int initialConnections) noexcept</td></tr>
<tr class="memdesc:a6c009b7305be563f672a42cc27a5d1a5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the number of initial connections in the pool.  <br /></td></tr>
<tr class="separator:a6c009b7305be563f672a42cc27a5d1a5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aafef0cc48a4a2d4ba0ed85dbc3755fa2" id="r_aafef0cc48a4a2d4ba0ed85dbc3755fa2"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aafef0cc48a4a2d4ba0ed85dbc3755fa2">getInitialConnections</a> () noexcept</td></tr>
<tr class="memdesc:aafef0cc48a4a2d4ba0ed85dbc3755fa2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets the number of initial connections in the pool.  <br /></td></tr>
<tr class="separator:aafef0cc48a4a2d4ba0ed85dbc3755fa2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeb2281180e1536441f3bba0960f7363b" id="r_aeb2281180e1536441f3bba0960f7363b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aeb2281180e1536441f3bba0960f7363b">setMaxConnections</a> (int maxConnections) noexcept</td></tr>
<tr class="memdesc:aeb2281180e1536441f3bba0960f7363b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the maximum number of connections in the pool.  <br /></td></tr>
<tr class="separator:aeb2281180e1536441f3bba0960f7363b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae5de2a152bc10a197d19d6894139e397" id="r_ae5de2a152bc10a197d19d6894139e397"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ae5de2a152bc10a197d19d6894139e397">getMaxConnections</a> () noexcept</td></tr>
<tr class="memdesc:ae5de2a152bc10a197d19d6894139e397"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets the maximum number of connections in the pool.  <br /></td></tr>
<tr class="separator:ae5de2a152bc10a197d19d6894139e397"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa87247f000aa4779555196cb8bd90aa4" id="r_aa87247f000aa4779555196cb8bd90aa4"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa87247f000aa4779555196cb8bd90aa4">setConnectionTimeout</a> (int connectionTimeout) noexcept</td></tr>
<tr class="memdesc:aa87247f000aa4779555196cb8bd90aa4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the connection inactive timeout value in seconds.  <br /></td></tr>
<tr class="separator:aa87247f000aa4779555196cb8bd90aa4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5d2715f6a222290bda34b07f3ac5be56" id="r_a5d2715f6a222290bda34b07f3ac5be56"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a5d2715f6a222290bda34b07f3ac5be56">getConnectionTimeout</a> () noexcept</td></tr>
<tr class="memdesc:a5d2715f6a222290bda34b07f3ac5be56"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets the connection timeout value.  <br /></td></tr>
<tr class="separator:a5d2715f6a222290bda34b07f3ac5be56"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8cfc56e2b3187d8a9b5d8e90829d9788" id="r_a8cfc56e2b3187d8a9b5d8e90829d9788"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a8cfc56e2b3187d8a9b5d8e90829d9788">setAbortHandler</a> (<a class="el" href="#aa8c093fe9d24e17623e90f2d448f3cd6">AbortHandler</a> abortHandler=nullptr) noexcept</td></tr>
<tr class="memdesc:a8cfc56e2b3187d8a9b5d8e90829d9788"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the function to call if a fatal error occurs in the library.  <br /></td></tr>
<tr class="separator:a8cfc56e2b3187d8a9b5d8e90829d9788"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8c3d08759971390eea0adb4954280396" id="r_a8c3d08759971390eea0adb4954280396"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a8c3d08759971390eea0adb4954280396">setReaper</a> (int sweepInterval) noexcept</td></tr>
<tr class="memdesc:a8c3d08759971390eea0adb4954280396"><td class="mdescLeft">&#160;</td><td class="mdescRight">Customizes the reaper thread behavior or disables it.  <br /></td></tr>
<tr class="separator:a8c3d08759971390eea0adb4954280396"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Member Typedef Documentation</h2>
<a id="aa8c093fe9d24e17623e90f2d448f3cd6" name="aa8c093fe9d24e17623e90f2d448f3cd6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa8c093fe9d24e17623e90f2d448f3cd6">&#9670;&#160;</a></span>AbortHandler</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">using <a class="el" href="#aa8c093fe9d24e17623e90f2d448f3cd6">AbortHandler</a> = std::function&lt;void(std::string_view)&gt;</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="ad00f5ab1a002c93b5fbf94f751513dad" name="ad00f5ab1a002c93b5fbf94f751513dad"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad00f5ab1a002c93b5fbf94f751513dad">&#9670;&#160;</a></span>ConnectionPool() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classzdb_1_1ConnectionPool.html">ConnectionPool</a> </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;</td>          <td class="paramname"><span class="paramname"><em>url</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">explicit</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Constructs a <a class="el" href="classzdb_1_1ConnectionPool.html" title="Represents a database connection pool.">ConnectionPool</a> with the given <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> string. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">url</td><td>The database connection <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> string. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classzdb_1_1sql__exception.html" title="Exception class for SQL related errors.">sql_exception</a></td><td>If the <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> is invalid. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="aa1765f7d950e6bc31f74222d29b7b809" name="aa1765f7d950e6bc31f74222d29b7b809"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa1765f7d950e6bc31f74222d29b7b809">&#9670;&#160;</a></span>ConnectionPool() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classzdb_1_1ConnectionPool.html">ConnectionPool</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classzdb_1_1URL.html">URL</a> &amp;&amp;</td>          <td class="paramname"><span class="paramname"><em>url</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">explicit</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Constructs a <a class="el" href="classzdb_1_1ConnectionPool.html" title="Represents a database connection pool.">ConnectionPool</a> with a <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> object. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">url</td><td>The database connection <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> object to move from. </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classzdb_1_1sql__exception.html" title="Exception class for SQL related errors.">sql_exception</a></td><td>If the <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> is invalid. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="ac260bbfdf88bc970fcd8ce49f4ee1fd2" name="ac260bbfdf88bc970fcd8ce49f4ee1fd2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac260bbfdf88bc970fcd8ce49f4ee1fd2">&#9670;&#160;</a></span>getType()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="ConnectionPool_8h.html#a6815bc519a92779e1565e92c0843eb23">CONNECTIONPOOL_TYPE</a> getType </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Retrieves the database type for this <a class="el" href="classzdb_1_1ConnectionPool.html" title="Represents a database connection pool.">ConnectionPool</a>. </p>
<dl class="section return"><dt>Returns</dt><dd>The CONNECTIONPOOL_TYPE representing the database backend for this <a class="el" href="classzdb_1_1ConnectionPool.html" title="Represents a database connection pool.">ConnectionPool</a> </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="ConnectionPool_8h.html#a6815bc519a92779e1565e92c0843eb23" title="Enumerates the supported database types for ConnectionPool.">CONNECTIONPOOL_TYPE</a> </dd></dl>

</div>
</div>
<a id="aff2fd69abe174f77bec9a7ed7812c52f" name="aff2fd69abe174f77bec9a7ed7812c52f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aff2fd69abe174f77bec9a7ed7812c52f">&#9670;&#160;</a></span>getURL()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="classzdb_1_1URL.html">URL</a> &amp; getURL </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Gets the <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> of the connection pool. </p>
<dl class="section return"><dt>Returns</dt><dd>The <a class="el" href="classzdb_1_1URL.html" title="Represents an immutable Uniform Resource Locator.">URL</a> of the connection pool. </dd></dl>

</div>
</div>
<a id="a6c009b7305be563f672a42cc27a5d1a5" name="a6c009b7305be563f672a42cc27a5d1a5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6c009b7305be563f672a42cc27a5d1a5">&#9670;&#160;</a></span>setInitialConnections()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void setInitialConnections </td>
          <td>(</td>
          <td class="paramtype">int</td>          <td class="paramname"><span class="paramname"><em>initialConnections</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Sets the number of initial connections in the pool. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">initialConnections</td><td>The number of initial connections. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="aafef0cc48a4a2d4ba0ed85dbc3755fa2" name="aafef0cc48a4a2d4ba0ed85dbc3755fa2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aafef0cc48a4a2d4ba0ed85dbc3755fa2">&#9670;&#160;</a></span>getInitialConnections()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int getInitialConnections </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Gets the number of initial connections in the pool. </p>
<dl class="section return"><dt>Returns</dt><dd>The number of initial connections. </dd></dl>

</div>
</div>
<a id="aeb2281180e1536441f3bba0960f7363b" name="aeb2281180e1536441f3bba0960f7363b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aeb2281180e1536441f3bba0960f7363b">&#9670;&#160;</a></span>setMaxConnections()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void setMaxConnections </td>
          <td>(</td>
          <td class="paramtype">int</td>          <td class="paramname"><span class="paramname"><em>maxConnections</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Sets the maximum number of connections in the pool. </p>
<p>If max connections has been reached, <a class="el" href="#abe00cdf87aed55bbe5ef191c248b62b1" title="Gets a connection from the pool.">getConnection()</a> will fail on the next call. It is a checked runtime error for maxConnections to be less than initialConnections.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">maxConnections</td><td>The maximum number of connections. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ae5de2a152bc10a197d19d6894139e397" name="ae5de2a152bc10a197d19d6894139e397"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae5de2a152bc10a197d19d6894139e397">&#9670;&#160;</a></span>getMaxConnections()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int getMaxConnections </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Gets the maximum number of connections in the pool. </p>
<dl class="section return"><dt>Returns</dt><dd>The maximum number of connections. </dd></dl>

</div>
</div>
<a id="aa87247f000aa4779555196cb8bd90aa4" name="aa87247f000aa4779555196cb8bd90aa4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa87247f000aa4779555196cb8bd90aa4">&#9670;&#160;</a></span>setConnectionTimeout()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void setConnectionTimeout </td>
          <td>(</td>
          <td class="paramtype">int</td>          <td class="paramname"><span class="paramname"><em>connectionTimeout</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Sets the connection inactive timeout value in seconds. </p>
<p>The method <a class="el" href="#a056cc693636467ed50b502fc2e841ef9" title="Reaps inactive connections in the pool.">reapConnections()</a>, if called, will close inactive connections in the pool which have not been in use for <code>connectionTimeout</code> seconds. The default connectionTimeout is 90 seconds.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">connectionTimeout</td><td>The timeout value in seconds. It is a checked runtime error for connectionTimeout to be &lt;= 0 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a5d2715f6a222290bda34b07f3ac5be56" name="a5d2715f6a222290bda34b07f3ac5be56"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5d2715f6a222290bda34b07f3ac5be56">&#9670;&#160;</a></span>getConnectionTimeout()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int getConnectionTimeout </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Gets the connection timeout value. </p>
<dl class="section return"><dt>Returns</dt><dd>The connection timeout value in seconds. </dd></dl>

</div>
</div>
<a id="a8cfc56e2b3187d8a9b5d8e90829d9788" name="a8cfc56e2b3187d8a9b5d8e90829d9788"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8cfc56e2b3187d8a9b5d8e90829d9788">&#9670;&#160;</a></span>setAbortHandler()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void setAbortHandler </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="#aa8c093fe9d24e17623e90f2d448f3cd6">AbortHandler</a></td>          <td class="paramname"><span class="paramname"><em>abortHandler</em></span><span class="paramdefsep"> = </span><span class="paramdefval">nullptr</span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Sets the function to call if a fatal error occurs in the library. </p>
<p>In practice this means Out-Of-Memory errors or uncaught exceptions. Clients may optionally provide this function. If not provided the library will call <code>abort(3)</code> or <code>exit(1)</code> upon encountering a fatal error. It is an unchecked runtime error to continue using the library after the <code>abortHandler</code> was called.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">abortHandler</td><td>The handler function to call on fatal errors. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a8c3d08759971390eea0adb4954280396" name="a8c3d08759971390eea0adb4954280396"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8c3d08759971390eea0adb4954280396">&#9670;&#160;</a></span>setReaper()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void setReaper </td>
          <td>(</td>
          <td class="paramtype">int</td>          <td class="paramname"><span class="paramname"><em>sweepInterval</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Customizes the reaper thread behavior or disables it. </p>
<p>By default, a reaper thread is automatically started when the pool is initialized, with a default sweep interval of 60 seconds. This method allows you to change the sweep interval or disable the reaper entirely.</p>
<p>The reaper thread closes inactive Connections in the pool, down to the initial connection count. An inactive <a class="el" href="classzdb_1_1Connection.html" title="Represents a connection to a SQL database system.">Connection</a> is closed if its <code>connectionTimeout</code> has expired or if it fails a ping test. Active Connections (those in current use) are never closed by this thread.</p>
<p>This method can be called before or after <a class="el" href="#a60de64d75454385b23995437f1d72669" title="Prepares the pool for active use.">ConnectionPool::start()</a>. If called after start, the changes will take effect on the next sweep cycle.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sweepInterval</td><td>Number of seconds between sweeps of the reaper thread. Set to 0 or a negative value to disable the reaper thread, <em>before</em> calling <a class="el" href="#a60de64d75454385b23995437f1d72669" title="Prepares the pool for active use.">ConnectionPool::start()</a>. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a80503477ad0a25944691f325362c12bc" name="a80503477ad0a25944691f325362c12bc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a80503477ad0a25944691f325362c12bc">&#9670;&#160;</a></span>size()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int size </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Gets the current number of connections in the pool. </p>
<dl class="section return"><dt>Returns</dt><dd>The total number of connections in the pool. </dd></dl>

</div>
</div>
<a id="af7b327acf6e895fd4fc85138bf88db66" name="af7b327acf6e895fd4fc85138bf88db66"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af7b327acf6e895fd4fc85138bf88db66">&#9670;&#160;</a></span>active()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int active </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Gets the number of active connections in the pool. </p>
<dl class="section return"><dt>Returns</dt><dd>The number of active connections in the pool. </dd></dl>

</div>
</div>
<a id="abf62facb0768c6757b21a1cb30f4a96d" name="abf62facb0768c6757b21a1cb30f4a96d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abf62facb0768c6757b21a1cb30f4a96d">&#9670;&#160;</a></span>isFull()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool isFull </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Checks if the pool is full. </p>
<p>The pool is full if the number of <em>active</em> connections equals max connections and the pool is unable to return a connection.</p>
<dl class="section return"><dt>Returns</dt><dd>true if pool is full, false otherwise </dd></dl>
<dl class="section note"><dt>Note</dt><dd>A full pool is unlikely to occur in practice if you ensure that connections are returned to the pool after use. </dd></dl>

</div>
</div>
<a id="a60de64d75454385b23995437f1d72669" name="a60de64d75454385b23995437f1d72669"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a60de64d75454385b23995437f1d72669">&#9670;&#160;</a></span>start()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void start </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Prepares the pool for active use. </p>
<p>This method must be called before the pool is used. It will connect to the database server, create the initial connections for the pool, and start the reaper thread with default settings, unless previously disabled via <a class="el" href="#a8c3d08759971390eea0adb4954280396" title="Customizes the reaper thread behavior or disables it.">setReaper()</a>.</p>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classzdb_1_1sql__exception.html" title="Exception class for SQL related errors.">sql_exception</a></td><td>If a database error occurs. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a8c528baf37154d347366083f0f816846" name="a8c528baf37154d347366083f0f816846"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8c528baf37154d347366083f0f816846">&#9670;&#160;</a></span>stop()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void stop </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Gracefully terminates the pool. </p>
<p>This method should be the last one called on a given instance of this component. Calling this method closes down all connections in the pool, disconnects the pool from the database server, and stops the reaper thread if it was started.</p>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classzdb_1_1sql__exception.html" title="Exception class for SQL related errors.">sql_exception</a></td><td>If there are active connections. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="abe00cdf87aed55bbe5ef191c248b62b1" name="abe00cdf87aed55bbe5ef191c248b62b1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abe00cdf87aed55bbe5ef191c248b62b1">&#9670;&#160;</a></span>getConnection()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classzdb_1_1Connection.html">Connection</a> getConnection </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">nodiscard</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Gets a connection from the pool. </p>
<p>The returned <a class="el" href="classzdb_1_1Connection.html" title="Represents a connection to a SQL database system.">Connection</a> is guaranteed to be alive and connected to the database.</p>
<p>An <a class="el" href="classzdb_1_1sql__exception.html" title="Exception class for SQL related errors.">sql_exception</a> may be thrown if the pool is full or if a database error occurs (e.g., network issues, database unavailability).</p>
<p>Here's a basic example of how to use getConnection and handle potential errors:</p>
<div class="fragment"><div class="line"><span class="keywordflow">try</span> {</div>
<div class="line">    <a class="code hl_class" href="classzdb_1_1Connection.html">Connection</a> con = pool.getConnection();</div>
<div class="line">    <span class="comment">// Use the connection ...</span></div>
<div class="line">} <span class="keywordflow">catch</span> (<span class="keyword">const</span> <a class="code hl_class" href="classzdb_1_1sql__exception.html">sql_exception</a>&amp; e) {</div>
<div class="line">    std::cerr &lt;&lt; <span class="stringliteral">&quot;Error: &quot;</span> &lt;&lt; e.what() &lt;&lt; std::endl;</div>
<div class="line">}</div>
<div class="ttc" id="aclasszdb_1_1sql__exception_html"><div class="ttname"><a href="classzdb_1_1sql__exception.html">zdb::sql_exception</a></div><div class="ttdoc">Exception class for SQL related errors.</div><div class="ttdef"><b>Definition</b> zdbpp.h:273</div></div>
</div><!-- fragment --><dl class="section return"><dt>Returns</dt><dd>A <a class="el" href="classzdb_1_1Connection.html" title="Represents a connection to a SQL database system.">Connection</a> object. </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classzdb_1_1sql__exception.html" title="Exception class for SQL related errors.">sql_exception</a></td><td>If a database connection cannot be obtained </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a1265c915e394316c05914d36138f552a" name="a1265c915e394316c05914d36138f552a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1265c915e394316c05914d36138f552a">&#9670;&#160;</a></span>returnConnection()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void returnConnection </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classzdb_1_1Connection.html">Connection</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>con</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Returns a connection to the pool. </p>
<p>The same as calling <a class="el" href="classzdb_1_1Connection.html#a2ead8fad3dd09d3a8b03e6c948f14e46" title="Returns the connection to the connection pool.">Connection::close()</a> on a connection. If the connection is in an uncommitted transaction, rollback is called. It is an unchecked error to attempt to use the <a class="el" href="classzdb_1_1Connection.html" title="Represents a connection to a SQL database system.">Connection</a> after this method is called.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">con</td><td>The <a class="el" href="classzdb_1_1Connection.html" title="Represents a connection to a SQL database system.">Connection</a> to return. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a056cc693636467ed50b502fc2e841ef9" name="a056cc693636467ed50b502fc2e841ef9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a056cc693636467ed50b502fc2e841ef9">&#9670;&#160;</a></span>reapConnections()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int reapConnections </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Reaps inactive connections in the pool. </p>
<dl class="section return"><dt>Returns</dt><dd>The number of connections reaped. </dd></dl>

</div>
</div>
</div><!-- contents -->
<p style="text-align:center;color:#808080;font-size:90%;margin:40px 0 20px 0;">
Copyright &copy; <a href="https://tildeslash.com/">Tildeslash Ltd</a>. All
rights reserved.</p>
</body></html>