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 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005
|
<!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.h File Reference</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&dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_bb61871b4c63e4e6685a8d6c52430594.html">zdb</a></li> </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
<div class="summary">
<a href="#define-members">Macros</a> |
<a href="#typedef-members">Typedefs</a> |
<a href="#enum-members">Enumerations</a> |
<a href="#func-members">Functions</a> |
<a href="#var-members">Variables</a> </div>
<div class="headertitle"><div class="title">ConnectionPool.h File Reference</div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>A <b>ConnectionPool</b> represents a database connection pool. </p>
<p>A connection pool can be used to get a connection 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 ConnectionPool objects as needed and against as many different database systems as needed. The following diagram gives an overview of the library's components and their method-associations:</p>
<center><img src="database.png" alt="" class="resp-img" style="width:700px" class="inline"/></center><p>The method <a class="el" href="#aeb9223e1addafed257e35e248c049097" title="Get a connection from the pool.">ConnectionPool_getConnection()</a> is used to obtain a new connection from the pool. If there are no connections available, a new connection is created and returned. If the pool has already handed out <em>maxConnections</em> Connections, the next call to <a class="el" href="#aeb9223e1addafed257e35e248c049097" title="Get a connection from the pool.">ConnectionPool_getConnection()</a> will return NULL. Use <a class="el" href="Connection_8h.html#aac4c939875fb240528435d486b484a7f" title="Returns the connection to the connection pool.">Connection_close()</a> to return a connection to the pool so it can be reused.</p>
<p>A connection pool is created by default with 5 initial connections and with 20 maximum connections. These values can be changed by the property methods <a class="el" href="#ae6c26352ee4fcbe05a97d5b6aba607f3" title="Sets the number of initial connections in the pool.">ConnectionPool_setInitialConnections()</a> and <a class="el" href="#a68ac953c1bc1915b3ac6ae0b7b4c64a4" title="Sets the maximum number of connections in the pool.">ConnectionPool_setMaxConnections()</a>.</p>
<h2><a class="anchor" id="autotoc_md4"></a>
Supported database systems:</h2>
<p>This library may be built with support for many different database systems. To test if a particular system is supported, use the method <a class="el" href="Connection_8h.html#acb342bb922ef5ad26829605340134f0e" title="Checks if the specified database system is supported.">Connection_isSupported()</a>.</p>
<h2><a class="anchor" id="autotoc_md5"></a>
Life-cycle methods:</h2>
<p>Clients should call <a class="el" href="#a8d7c529ccb99d0345e0c8524dba7281d" title="Prepares the pool for active use.">ConnectionPool_start()</a> to establish the connection pool against the database server before using the pool. To shutdown connections from the database server, use <a class="el" href="#ac467a51ff4471989abbe07be1870072d" title="Gracefully terminates the pool.">ConnectionPool_stop()</a>. Set preferred properties <em>before</em> calling <a class="el" href="#a8d7c529ccb99d0345e0c8524dba7281d" title="Prepares the pool for active use.">ConnectionPool_start()</a>. Some properties can also be changed dynamically after the pool was started, such as changing the maximum number of connections or the number of initial connections. Changing and tuning these properties at runtime is most useful if the pool was started with a reaper-thread (see below) since the reaper dynamically changes the size of the pool.</p>
<h2><a class="anchor" id="autotoc_md6"></a>
Connection URL:</h2>
<p>The URL given to a Connection Pool at creation time specifies a database connection in the standard URL format. The format of the connection URL is defined as:</p>
<pre>
database://[user:password@][host][:port]/database[?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
</pre><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 URL. If port number is omitted, the default port number for the database server is used.</p>
<h3><a class="anchor" id="autotoc_md7"></a>
MySQL:</h3>
<p>Here is an example of how to connect to a <a href="http://www.mysql.org/">MySQL</a> database server:</p>
<div class="fragment"><div class="line">mysql:<span class="comment">//localhost:3306/test?user=root&password=swordfish</span></div>
</div><!-- fragment --><p>In this case, the username, <code>root</code> and password, <code>swordfish</code> are specified as properties to the URL. An alternative is to use the auth-part of the URL to specify authentication information:</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 URL.</p>
<h3><a class="anchor" id="autotoc_md8"></a>
SQLite:</h3>
<p>For a <a href="http://www.sqlite.org/">SQLite</a> database, the connection URL should simply specify a database file, since a SQLite database is just a file in the filesystem. 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 URL and will be set when the Connection is created. 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>A URL for connecting to a SQLite database might look like this (with recommended pragmas):</p>
<div class="fragment"><div class="line">sqlite:<span class="comment">///var/sqlite/test.db?synchronous=normal&foreign_keys=on&journal_mode=wal&temp_store=memory</span></div>
</div><!-- fragment --><h3><a class="anchor" id="autotoc_md9"></a>
PostgreSQL:</h3>
<p>The URL for connecting to a <a href="http://www.postgresql.org/">PostgreSQL</a> database server might look like:</p>
<div class="fragment"><div class="line">postgresql:<span class="comment">//localhost:5432/test?user=root&password=swordfish</span></div>
</div><!-- fragment --><p>As with the MySQL URL, the username and password are specified as properties to the URL. Likewise, the auth-part of the URL can be used instead to specify the username and the password:</p>
<div class="fragment"><div class="line">postgresql:<span class="comment">//root:swordfish@localhost/test?use-ssl=true</span></div>
</div><!-- fragment --><p>In this example, we have also omitted the port number to the server, in which case the default port number, <em>5432</em>, for PostgreSQL is used. In addition, we have added an extra parameter to the URL, so connection to the server is done over a secure SSL connection.</p>
<p>See <a href="postgresoptions.html">postgresql options</a> for all properties that can be set for a postgresql connection URL.</p>
<h3><a class="anchor" id="autotoc_md10"></a>
Oracle:</h3>
<p>The URL for connecting to an <a href="http://www.oracle.com/">Oracle</a> database server might look like:</p>
<div class="fragment"><div class="line">oracle:<span class="comment">//localhost:1521/servicename?user=scott&password=tiger</span></div>
</div><!-- fragment --><p>Instead of a database name, Oracle uses a service name which you typically specify in a <code>tnsnames.ora</code> configuration file. The auth-part of the URL can be used instead to specify the username and the password as in the example below. Here we also specify that we want to connect to Oracle with the 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 URL.</p>
<h2><a class="anchor" id="autotoc_md11"></a>
Example:</h2>
<p>To obtain a connection pool for a MySQL database, the code below can be used. The exact same code can be used for PostgreSQL, SQLite and Oracle, the only change needed is to modify the Connection URL. Here we connect to the database test on localhost and start the pool with the default 5 initial connections.</p>
<div class="fragment"><div class="line">URL_T url = <a class="code hl_function" href="URL_8h.html#a1e85f50a8c6036c34b642a49cc08d5fb">URL_new</a>(<span class="stringliteral">"mysql://localhost/test?user=root&password=swordfish"</span>);</div>
<div class="line">ConnectionPool_T pool = <a class="code hl_function" href="#aa808a931fc4e79ff34941ee5a46de8cb">ConnectionPool_new</a>(url);</div>
<div class="line"><a class="code hl_function" href="#a8d7c529ccb99d0345e0c8524dba7281d">ConnectionPool_start</a>(pool);</div>
<div class="line"><span class="comment">//..</span></div>
<div class="line">Connection_T con = <a class="code hl_function" href="#aeb9223e1addafed257e35e248c049097">ConnectionPool_getConnection</a>(pool);</div>
<div class="line">ResultSet_T result = <a class="code hl_function" href="Connection_8h.html#a3d1e39204654573ccac3d8ba3a2eae58">Connection_executeQuery</a>(con, <span class="stringliteral">"select id, name, photo from employee where salary>%d"</span>, anumber);</div>
<div class="line"><span class="keywordflow">while</span> (<a class="code hl_function" href="ResultSet_8h.html#a771894bb8c0ddfd90ed6ed9c9c3e46b3">ResultSet_next</a>(result))</div>
<div class="line">{</div>
<div class="line"> <span class="keywordtype">int</span> <span class="keywordtype">id</span> = <a class="code hl_function" href="ResultSet_8h.html#aa73672053b34ee50c21eac0783b28719">ResultSet_getInt</a>(result, 1);</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *name = <a class="code hl_function" href="ResultSet_8h.html#ac65ad967dcaad62aa13d166c446e8f58">ResultSet_getString</a>(result, 2);</div>
<div class="line"> <span class="keywordtype">int</span> blobSize;</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">void</span> *photo = <a class="code hl_function" href="ResultSet_8h.html#adee072900d8136c0d6bd0596388f1e83">ResultSet_getBlob</a>(result, 3, &blobSize);</div>
<div class="line"> <span class="comment">// ...</span></div>
<div class="line">}</div>
<div class="line"><a class="code hl_function" href="Connection_8h.html#aac4c939875fb240528435d486b484a7f">Connection_close</a>(con);</div>
<div class="line"><span class="comment">//..</span></div>
<div class="line"><a class="code hl_function" href="#a6ca3943e0f711030bf0bf3cf83e0abef">ConnectionPool_free</a>(&pool);</div>
<div class="line"><a class="code hl_function" href="URL_8h.html#ad3dc09880813e8dd994333ae37534c0d">URL_free</a>(&url);</div>
<div class="ttc" id="aConnectionPool_8h_html_a6ca3943e0f711030bf0bf3cf83e0abef"><div class="ttname"><a href="#a6ca3943e0f711030bf0bf3cf83e0abef">ConnectionPool_free</a></div><div class="ttdeci">void ConnectionPool_free(T *P)</div><div class="ttdoc">Disconnect and destroy the pool and release allocated resources.</div></div>
<div class="ttc" id="aConnectionPool_8h_html_a8d7c529ccb99d0345e0c8524dba7281d"><div class="ttname"><a href="#a8d7c529ccb99d0345e0c8524dba7281d">ConnectionPool_start</a></div><div class="ttdeci">void ConnectionPool_start(T P)</div><div class="ttdoc">Prepares the pool for active use.</div></div>
<div class="ttc" id="aConnectionPool_8h_html_aa808a931fc4e79ff34941ee5a46de8cb"><div class="ttname"><a href="#aa808a931fc4e79ff34941ee5a46de8cb">ConnectionPool_new</a></div><div class="ttdeci">T ConnectionPool_new(URL_T url)</div><div class="ttdoc">Create a new ConnectionPool.</div></div>
<div class="ttc" id="aConnectionPool_8h_html_aeb9223e1addafed257e35e248c049097"><div class="ttname"><a href="#aeb9223e1addafed257e35e248c049097">ConnectionPool_getConnection</a></div><div class="ttdeci">Connection_T ConnectionPool_getConnection(T P)</div><div class="ttdoc">Get a connection from the pool.</div></div>
<div class="ttc" id="aConnection_8h_html_a3d1e39204654573ccac3d8ba3a2eae58"><div class="ttname"><a href="Connection_8h.html#a3d1e39204654573ccac3d8ba3a2eae58">Connection_executeQuery</a></div><div class="ttdeci">ResultSet_T Connection_executeQuery(T C, const char *sql,...)</div><div class="ttdoc">Executes a SQL query and returns a ResultSet.</div></div>
<div class="ttc" id="aConnection_8h_html_aac4c939875fb240528435d486b484a7f"><div class="ttname"><a href="Connection_8h.html#aac4c939875fb240528435d486b484a7f">Connection_close</a></div><div class="ttdeci">void Connection_close(T C)</div><div class="ttdoc">Returns the connection to the connection pool.</div></div>
<div class="ttc" id="aResultSet_8h_html_a771894bb8c0ddfd90ed6ed9c9c3e46b3"><div class="ttname"><a href="ResultSet_8h.html#a771894bb8c0ddfd90ed6ed9c9c3e46b3">ResultSet_next</a></div><div class="ttdeci">bool ResultSet_next(T R)</div><div class="ttdoc">Moves the cursor to the next row.</div></div>
<div class="ttc" id="aResultSet_8h_html_aa73672053b34ee50c21eac0783b28719"><div class="ttname"><a href="ResultSet_8h.html#aa73672053b34ee50c21eac0783b28719">ResultSet_getInt</a></div><div class="ttdeci">int ResultSet_getInt(T R, int columnIndex)</div><div class="ttdoc">Gets the designated column's value as an int.</div></div>
<div class="ttc" id="aResultSet_8h_html_ac65ad967dcaad62aa13d166c446e8f58"><div class="ttname"><a href="ResultSet_8h.html#ac65ad967dcaad62aa13d166c446e8f58">ResultSet_getString</a></div><div class="ttdeci">const char * ResultSet_getString(T R, int columnIndex)</div><div class="ttdoc">Gets the designated column's value as a C-string.</div></div>
<div class="ttc" id="aResultSet_8h_html_adee072900d8136c0d6bd0596388f1e83"><div class="ttname"><a href="ResultSet_8h.html#adee072900d8136c0d6bd0596388f1e83">ResultSet_getBlob</a></div><div class="ttdeci">const void * ResultSet_getBlob(T R, int columnIndex, int *size)</div><div class="ttdoc">Gets the designated column's value as a void pointer.</div></div>
<div class="ttc" id="aURL_8h_html_a1e85f50a8c6036c34b642a49cc08d5fb"><div class="ttname"><a href="URL_8h.html#a1e85f50a8c6036c34b642a49cc08d5fb">URL_new</a></div><div class="ttdeci">T URL_new(const char *url)</div><div class="ttdoc">Create a new URL object from the url parameter string.</div></div>
<div class="ttc" id="aURL_8h_html_ad3dc09880813e8dd994333ae37534c0d"><div class="ttname"><a href="URL_8h.html#ad3dc09880813e8dd994333ae37534c0d">URL_free</a></div><div class="ttdeci">void URL_free(T *U)</div><div class="ttdoc">Destroy a URL object.</div></div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md12"></a>
Optimizing the pool size:</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>
<p>This dual functionality helps maintain the pool's health by removing stale connections and verifying the validity of idle ones.</p>
<p>Only inactive connections will be closed, and no more than the initial number of connections the pool was started with are closed. The property method, <code><a class="el" href="#a756268df598fb93caeef570b775e6768" title="Customize the reaper thread behavior or disable it.">ConnectionPool_setReaper()</a></code>, can be used to customize the reaper's sweep interval or disable it entirely if needed.</p>
<p>Clients can also call the method <code><a class="el" href="#a75e9b1e5c943a5bb76573a04268e496a" title="Reaps inactive connections in the pool.">ConnectionPool_reapConnections()</a></code> to prune the pool directly if manual control is desired.</p>
<p>The reaper thread is especially beneficial for pools maintaining TCP/IP Connections.</p>
<h2><a class="anchor" id="autotoc_md13"></a>
Realtime inspection:</h2>
<p>Three methods can be used to inspect the pool at runtime. The method <a class="el" href="#a76aacfe23b7708d436347107aedf0d15" title="Gets the current number of connections in the pool.">ConnectionPool_size()</a> returns the number of connections in the pool, that is, both active and inactive connections. The method <a class="el" href="#a3c54f3a36f5dd94b2c622c01010df15f" title="Gets the number of active connections in the pool.">ConnectionPool_active()</a> returns the number of active connections, i.e., those connections in current use by your application. The method <a class="el" href="#a1476a21ddfa994f43ffd14dc52b15b9b" title="Checks if the pool is full.">ConnectionPool_isFull()</a> can be used to check if the pool is full and unable to return a connection.</p>
<p><em>This ConnectionPool is thread-safe.</em></p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="Connection_8h.html" title="A Connection represents a connection to a SQL database system.">Connection.h</a> <a class="el" href="ResultSet_8h.html" title="A ResultSet represents a database result set.">ResultSet.h</a> <a class="el" href="URL_8h.html" title="URL represents an immutable Uniform Resource Locator.">URL.h</a> <a class="el" href="PreparedStatement_8h.html" title="A PreparedStatement represents a single SQL statement pre-compiled into byte code for later execution...">PreparedStatement.h</a> <a class="el" href="SQLException_8h.html" title="Signals that an SQL specific exception has occurred.">SQLException.h</a> </dd></dl>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a0acb682b8260ab1c60b918599864e2e5" id="r_a0acb682b8260ab1c60b918599864e2e5"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="#a0acb682b8260ab1c60b918599864e2e5">T</a>   ConnectionPool_T</td></tr>
<tr class="separator:a0acb682b8260ab1c60b918599864e2e5"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ab61378ab62626de3ff80272e186394b3" id="r_ab61378ab62626de3ff80272e186394b3"><td class="memItemLeft" align="right" valign="top">typedef struct ConnectionPool_S * </td><td class="memItemRight" valign="bottom"><a class="el" href="#ab61378ab62626de3ff80272e186394b3">T</a></td></tr>
<tr class="separator:ab61378ab62626de3ff80272e186394b3"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="enum-members" name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:a6815bc519a92779e1565e92c0843eb23" id="r_a6815bc519a92779e1565e92c0843eb23"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="#a6815bc519a92779e1565e92c0843eb23">CONNECTIONPOOL_TYPE</a> { <br />
  <a class="el" href="#a6815bc519a92779e1565e92c0843eb23a6537435d00bd71b5a29df2a57a0ff3a8">CONNECTIONPOOL_NONE</a> = 0
, <a class="el" href="#a6815bc519a92779e1565e92c0843eb23a65702b9e22f65663a222a4e9626a703e">CONNECTIONPOOL_SQLITE</a>
, <a class="el" href="#a6815bc519a92779e1565e92c0843eb23ab82b9ee3901e315a9727a79e38a6212c">CONNECTIONPOOL_MYSQL</a>
, <a class="el" href="#a6815bc519a92779e1565e92c0843eb23ac96acd69d707dc1e157c670013117235">CONNECTIONPOOL_POSTGRESQL</a>
, <br />
  <a class="el" href="#a6815bc519a92779e1565e92c0843eb23ac8742f4771eabd05976e6dd2abb089fc">CONNECTIONPOOL_ORACLE</a>
<br />
}</td></tr>
<tr class="memdesc:a6815bc519a92779e1565e92c0843eb23"><td class="mdescLeft"> </td><td class="mdescRight">Enumerates the supported database types for ConnectionPool. <a href="#a6815bc519a92779e1565e92c0843eb23">More...</a><br /></td></tr>
<tr class="separator:a6815bc519a92779e1565e92c0843eb23"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:aa808a931fc4e79ff34941ee5a46de8cb" id="r_aa808a931fc4e79ff34941ee5a46de8cb"><td class="memItemLeft" align="right" valign="top"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#aa808a931fc4e79ff34941ee5a46de8cb">ConnectionPool_new</a> (URL_T url)</td></tr>
<tr class="memdesc:aa808a931fc4e79ff34941ee5a46de8cb"><td class="mdescLeft"> </td><td class="mdescRight">Create a new ConnectionPool. <br /></td></tr>
<tr class="separator:aa808a931fc4e79ff34941ee5a46de8cb"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a6ca3943e0f711030bf0bf3cf83e0abef" id="r_a6ca3943e0f711030bf0bf3cf83e0abef"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#a6ca3943e0f711030bf0bf3cf83e0abef">ConnectionPool_free</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> *P)</td></tr>
<tr class="memdesc:a6ca3943e0f711030bf0bf3cf83e0abef"><td class="mdescLeft"> </td><td class="mdescRight">Disconnect and destroy the pool and release allocated resources. <br /></td></tr>
<tr class="separator:a6ca3943e0f711030bf0bf3cf83e0abef"><td class="memSeparator" colspan="2"> </td></tr>
<tr><td colspan="2"><div class="groupHeader">Properties</div></td></tr>
<tr class="memitem:ab1b9eb1816dd9522498ac7be56b2e077" id="r_ab1b9eb1816dd9522498ac7be56b2e077"><td class="memItemLeft" align="right" valign="top"><a class="el" href="#a6815bc519a92779e1565e92c0843eb23">CONNECTIONPOOL_TYPE</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#ab1b9eb1816dd9522498ac7be56b2e077">ConnectionPool_getType</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P)</td></tr>
<tr class="memdesc:ab1b9eb1816dd9522498ac7be56b2e077"><td class="mdescLeft"> </td><td class="mdescRight">Retrieves the database type for this ConnectionPool. <br /></td></tr>
<tr class="separator:ab1b9eb1816dd9522498ac7be56b2e077"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a58a3cd3c193bd0d51a987a15539e3b48" id="r_a58a3cd3c193bd0d51a987a15539e3b48"><td class="memItemLeft" align="right" valign="top">URL_T </td><td class="memItemRight" valign="bottom"><a class="el" href="#a58a3cd3c193bd0d51a987a15539e3b48">ConnectionPool_getURL</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P)</td></tr>
<tr class="memdesc:a58a3cd3c193bd0d51a987a15539e3b48"><td class="mdescLeft"> </td><td class="mdescRight">Returns this Connection Pool's URL. <br /></td></tr>
<tr class="separator:a58a3cd3c193bd0d51a987a15539e3b48"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ae6c26352ee4fcbe05a97d5b6aba607f3" id="r_ae6c26352ee4fcbe05a97d5b6aba607f3"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#ae6c26352ee4fcbe05a97d5b6aba607f3">ConnectionPool_setInitialConnections</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P, int initialConnections)</td></tr>
<tr class="memdesc:ae6c26352ee4fcbe05a97d5b6aba607f3"><td class="mdescLeft"> </td><td class="mdescRight">Sets the number of initial connections in the pool. <br /></td></tr>
<tr class="separator:ae6c26352ee4fcbe05a97d5b6aba607f3"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aa6a2130831722010e89924aec17fe561" id="r_aa6a2130831722010e89924aec17fe561"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#aa6a2130831722010e89924aec17fe561">ConnectionPool_getInitialConnections</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P)</td></tr>
<tr class="memdesc:aa6a2130831722010e89924aec17fe561"><td class="mdescLeft"> </td><td class="mdescRight">Gets the number of initial connections in the pool. <br /></td></tr>
<tr class="separator:aa6a2130831722010e89924aec17fe561"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a68ac953c1bc1915b3ac6ae0b7b4c64a4" id="r_a68ac953c1bc1915b3ac6ae0b7b4c64a4"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#a68ac953c1bc1915b3ac6ae0b7b4c64a4">ConnectionPool_setMaxConnections</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P, int maxConnections)</td></tr>
<tr class="memdesc:a68ac953c1bc1915b3ac6ae0b7b4c64a4"><td class="mdescLeft"> </td><td class="mdescRight">Sets the maximum number of connections in the pool. <br /></td></tr>
<tr class="separator:a68ac953c1bc1915b3ac6ae0b7b4c64a4"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a5edf7736ec825e4a1aafd4f7f85c24d5" id="r_a5edf7736ec825e4a1aafd4f7f85c24d5"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#a5edf7736ec825e4a1aafd4f7f85c24d5">ConnectionPool_getMaxConnections</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P)</td></tr>
<tr class="memdesc:a5edf7736ec825e4a1aafd4f7f85c24d5"><td class="mdescLeft"> </td><td class="mdescRight">Gets the maximum number of connections in the pool. <br /></td></tr>
<tr class="separator:a5edf7736ec825e4a1aafd4f7f85c24d5"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a143b4171cc03227b1bca5cd10e724bc5" id="r_a143b4171cc03227b1bca5cd10e724bc5"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#a143b4171cc03227b1bca5cd10e724bc5">ConnectionPool_setConnectionTimeout</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P, int connectionTimeout)</td></tr>
<tr class="memdesc:a143b4171cc03227b1bca5cd10e724bc5"><td class="mdescLeft"> </td><td class="mdescRight">Set the Connection inactive timeout value in seconds. <br /></td></tr>
<tr class="separator:a143b4171cc03227b1bca5cd10e724bc5"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ad2dabf50cf0b9710848eba40c58bf748" id="r_ad2dabf50cf0b9710848eba40c58bf748"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#ad2dabf50cf0b9710848eba40c58bf748">ConnectionPool_getConnectionTimeout</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P)</td></tr>
<tr class="memdesc:ad2dabf50cf0b9710848eba40c58bf748"><td class="mdescLeft"> </td><td class="mdescRight">Gets the connection timeout value. <br /></td></tr>
<tr class="separator:ad2dabf50cf0b9710848eba40c58bf748"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a23b8c11de2c910a5ce75b008291ee22a" id="r_a23b8c11de2c910a5ce75b008291ee22a"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#a23b8c11de2c910a5ce75b008291ee22a">ConnectionPool_setAbortHandler</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P, void(*abortHandler)(const char *error))</td></tr>
<tr class="memdesc:a23b8c11de2c910a5ce75b008291ee22a"><td class="mdescLeft"> </td><td class="mdescRight">Sets the function to call if a fatal error occurs in the library. <br /></td></tr>
<tr class="separator:a23b8c11de2c910a5ce75b008291ee22a"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a756268df598fb93caeef570b775e6768" id="r_a756268df598fb93caeef570b775e6768"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#a756268df598fb93caeef570b775e6768">ConnectionPool_setReaper</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P, int sweepInterval)</td></tr>
<tr class="memdesc:a756268df598fb93caeef570b775e6768"><td class="mdescLeft"> </td><td class="mdescRight">Customize the reaper thread behavior or disable it. <br /></td></tr>
<tr class="separator:a756268df598fb93caeef570b775e6768"><td class="memSeparator" colspan="2"> </td></tr>
<tr><td colspan="2"><div class="groupHeader">Functions</div></td></tr>
<tr class="memitem:a8d7c529ccb99d0345e0c8524dba7281d" id="r_a8d7c529ccb99d0345e0c8524dba7281d"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#a8d7c529ccb99d0345e0c8524dba7281d">ConnectionPool_start</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P)</td></tr>
<tr class="memdesc:a8d7c529ccb99d0345e0c8524dba7281d"><td class="mdescLeft"> </td><td class="mdescRight">Prepares the pool for active use. <br /></td></tr>
<tr class="separator:a8d7c529ccb99d0345e0c8524dba7281d"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ac467a51ff4471989abbe07be1870072d" id="r_ac467a51ff4471989abbe07be1870072d"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#ac467a51ff4471989abbe07be1870072d">ConnectionPool_stop</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P)</td></tr>
<tr class="memdesc:ac467a51ff4471989abbe07be1870072d"><td class="mdescLeft"> </td><td class="mdescRight">Gracefully terminates the pool. <br /></td></tr>
<tr class="separator:ac467a51ff4471989abbe07be1870072d"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aeb9223e1addafed257e35e248c049097" id="r_aeb9223e1addafed257e35e248c049097"><td class="memItemLeft" align="right" valign="top">Connection_T </td><td class="memItemRight" valign="bottom"><a class="el" href="#aeb9223e1addafed257e35e248c049097">ConnectionPool_getConnection</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P)</td></tr>
<tr class="memdesc:aeb9223e1addafed257e35e248c049097"><td class="mdescLeft"> </td><td class="mdescRight">Get a connection from the pool. <br /></td></tr>
<tr class="separator:aeb9223e1addafed257e35e248c049097"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aa9a93750f071e29530e66e5b4bcda865" id="r_aa9a93750f071e29530e66e5b4bcda865"><td class="memItemLeft" align="right" valign="top">Connection_T </td><td class="memItemRight" valign="bottom"><a class="el" href="#aa9a93750f071e29530e66e5b4bcda865">ConnectionPool_getConnectionOrException</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P)</td></tr>
<tr class="memdesc:aa9a93750f071e29530e66e5b4bcda865"><td class="mdescLeft"> </td><td class="mdescRight">Get a connection from the pool. <br /></td></tr>
<tr class="separator:aa9a93750f071e29530e66e5b4bcda865"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a5d1f04dc0ae5fc42707dfd934f681c4a" id="r_a5d1f04dc0ae5fc42707dfd934f681c4a"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#a5d1f04dc0ae5fc42707dfd934f681c4a">ConnectionPool_returnConnection</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P, Connection_T connection)</td></tr>
<tr class="memdesc:a5d1f04dc0ae5fc42707dfd934f681c4a"><td class="mdescLeft"> </td><td class="mdescRight">Returns a connection to the pool. <br /></td></tr>
<tr class="separator:a5d1f04dc0ae5fc42707dfd934f681c4a"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a75e9b1e5c943a5bb76573a04268e496a" id="r_a75e9b1e5c943a5bb76573a04268e496a"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#a75e9b1e5c943a5bb76573a04268e496a">ConnectionPool_reapConnections</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P)</td></tr>
<tr class="memdesc:a75e9b1e5c943a5bb76573a04268e496a"><td class="mdescLeft"> </td><td class="mdescRight">Reaps inactive connections in the pool. <br /></td></tr>
<tr class="separator:a75e9b1e5c943a5bb76573a04268e496a"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a76aacfe23b7708d436347107aedf0d15" id="r_a76aacfe23b7708d436347107aedf0d15"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#a76aacfe23b7708d436347107aedf0d15">ConnectionPool_size</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P)</td></tr>
<tr class="memdesc:a76aacfe23b7708d436347107aedf0d15"><td class="mdescLeft"> </td><td class="mdescRight">Gets the current number of connections in the pool. <br /></td></tr>
<tr class="separator:a76aacfe23b7708d436347107aedf0d15"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a3c54f3a36f5dd94b2c622c01010df15f" id="r_a3c54f3a36f5dd94b2c622c01010df15f"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#a3c54f3a36f5dd94b2c622c01010df15f">ConnectionPool_active</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P)</td></tr>
<tr class="memdesc:a3c54f3a36f5dd94b2c622c01010df15f"><td class="mdescLeft"> </td><td class="mdescRight">Gets the number of active connections in the pool. <br /></td></tr>
<tr class="separator:a3c54f3a36f5dd94b2c622c01010df15f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a1476a21ddfa994f43ffd14dc52b15b9b" id="r_a1476a21ddfa994f43ffd14dc52b15b9b"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="#a1476a21ddfa994f43ffd14dc52b15b9b">ConnectionPool_isFull</a> (<a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> P)</td></tr>
<tr class="memdesc:a1476a21ddfa994f43ffd14dc52b15b9b"><td class="mdescLeft"> </td><td class="mdescRight">Checks if the pool is full. <br /></td></tr>
<tr class="separator:a1476a21ddfa994f43ffd14dc52b15b9b"><td class="memSeparator" colspan="2"> </td></tr>
<tr><td colspan="2"><div class="groupHeader">Class functions</div></td></tr>
<tr class="memitem:a7239f3b5265f6b10cb147fa9a6cc498d" id="r_a7239f3b5265f6b10cb147fa9a6cc498d"><td class="memItemLeft" align="right" valign="top">const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="#a7239f3b5265f6b10cb147fa9a6cc498d">ConnectionPool_version</a> (void)</td></tr>
<tr class="memdesc:a7239f3b5265f6b10cb147fa9a6cc498d"><td class="mdescLeft"> </td><td class="mdescRight">Gets the library version information. <br /></td></tr>
<tr class="separator:a7239f3b5265f6b10cb147fa9a6cc498d"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="var-members" name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:a7886fb40d7187a54bb9a5ef8899616ce" id="r_a7886fb40d7187a54bb9a5ef8899616ce"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#a7886fb40d7187a54bb9a5ef8899616ce">ZBDEBUG</a></td></tr>
<tr class="memdesc:a7886fb40d7187a54bb9a5ef8899616ce"><td class="mdescLeft"> </td><td class="mdescRight">Library Debug flag. <br /></td></tr>
<tr class="separator:a7886fb40d7187a54bb9a5ef8899616ce"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a id="a0acb682b8260ab1c60b918599864e2e5" name="a0acb682b8260ab1c60b918599864e2e5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0acb682b8260ab1c60b918599864e2e5">◆ </a></span>T</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define <a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a>   ConnectionPool_T</td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<h2 class="groupheader">Typedef Documentation</h2>
<a id="ab61378ab62626de3ff80272e186394b3" name="ab61378ab62626de3ff80272e186394b3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab61378ab62626de3ff80272e186394b3">◆ </a></span>T</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef struct ConnectionPool_S* <a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a id="a6815bc519a92779e1565e92c0843eb23" name="a6815bc519a92779e1565e92c0843eb23"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6815bc519a92779e1565e92c0843eb23">◆ </a></span>CONNECTIONPOOL_TYPE</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">enum <a class="el" href="#a6815bc519a92779e1565e92c0843eb23">CONNECTIONPOOL_TYPE</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>Enumerates the supported database types for ConnectionPool. </p>
<p>This enum defines the various database backends that can be used with the ConnectionPool in the libzdb library. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="a6815bc519a92779e1565e92c0843eb23a6537435d00bd71b5a29df2a57a0ff3a8" name="a6815bc519a92779e1565e92c0843eb23a6537435d00bd71b5a29df2a57a0ff3a8"></a>CONNECTIONPOOL_NONE </td><td class="fielddoc"><p>No database type set (default/uninitialized state) </p>
</td></tr>
<tr><td class="fieldname"><a id="a6815bc519a92779e1565e92c0843eb23a65702b9e22f65663a222a4e9626a703e" name="a6815bc519a92779e1565e92c0843eb23a65702b9e22f65663a222a4e9626a703e"></a>CONNECTIONPOOL_SQLITE </td><td class="fielddoc"><p>SQLite database connection. </p>
</td></tr>
<tr><td class="fieldname"><a id="a6815bc519a92779e1565e92c0843eb23ab82b9ee3901e315a9727a79e38a6212c" name="a6815bc519a92779e1565e92c0843eb23ab82b9ee3901e315a9727a79e38a6212c"></a>CONNECTIONPOOL_MYSQL </td><td class="fielddoc"><p>MySQL database connection. </p>
</td></tr>
<tr><td class="fieldname"><a id="a6815bc519a92779e1565e92c0843eb23ac96acd69d707dc1e157c670013117235" name="a6815bc519a92779e1565e92c0843eb23ac96acd69d707dc1e157c670013117235"></a>CONNECTIONPOOL_POSTGRESQL </td><td class="fielddoc"><p>PostgreSQL database connection. </p>
</td></tr>
<tr><td class="fieldname"><a id="a6815bc519a92779e1565e92c0843eb23ac8742f4771eabd05976e6dd2abb089fc" name="a6815bc519a92779e1565e92c0843eb23ac8742f4771eabd05976e6dd2abb089fc"></a>CONNECTIONPOOL_ORACLE </td><td class="fielddoc"><p>Oracle database connection. </p>
</td></tr>
</table>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="aa808a931fc4e79ff34941ee5a46de8cb" name="aa808a931fc4e79ff34941ee5a46de8cb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa808a931fc4e79ff34941ee5a46de8cb">◆ </a></span>ConnectionPool_new()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> ConnectionPool_new </td>
<td>(</td>
<td class="paramtype">URL_T</td> <td class="paramname"><span class="paramname"><em>url</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Create a new ConnectionPool. </p>
<p>The pool is created with 5 initial connections. Maximum connections is set to 20. Property methods in this interface can be used to change the default values.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">url</td><td>The database connection URL. It is a checked runtime error for the url parameter to be NULL. The pool <b>does not</b> take ownership of the <code>url</code> object but expects the url to exist as long as the pool does. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>A new ConnectionPool object </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="URL_8h.html" title="URL represents an immutable Uniform Resource Locator.">URL.h</a> </dd></dl>
</div>
</div>
<a id="a6ca3943e0f711030bf0bf3cf83e0abef" name="a6ca3943e0f711030bf0bf3cf83e0abef"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6ca3943e0f711030bf0bf3cf83e0abef">◆ </a></span>ConnectionPool_free()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ConnectionPool_free </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a> *</td> <td class="paramname"><span class="paramname"><em>P</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Disconnect and destroy the pool and release allocated resources. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object reference </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="ab1b9eb1816dd9522498ac7be56b2e077" name="ab1b9eb1816dd9522498ac7be56b2e077"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab1b9eb1816dd9522498ac7be56b2e077">◆ </a></span>ConnectionPool_getType()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="#a6815bc519a92779e1565e92c0843eb23">CONNECTIONPOOL_TYPE</a> ConnectionPool_getType </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Retrieves the database type for this ConnectionPool. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The CONNECTIONPOOL_TYPE representing the database backend for this ConnectionPool </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="#a6815bc519a92779e1565e92c0843eb23" title="Enumerates the supported database types for ConnectionPool.">CONNECTIONPOOL_TYPE</a> </dd></dl>
</div>
</div>
<a id="a58a3cd3c193bd0d51a987a15539e3b48" name="a58a3cd3c193bd0d51a987a15539e3b48"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a58a3cd3c193bd0d51a987a15539e3b48">◆ </a></span>ConnectionPool_getURL()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">URL_T ConnectionPool_getURL </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns this Connection Pool's URL. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>This Connection Pool's URL </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="URL_8h.html" title="URL represents an immutable Uniform Resource Locator.">URL.h</a> </dd></dl>
</div>
</div>
<a id="ae6c26352ee4fcbe05a97d5b6aba607f3" name="ae6c26352ee4fcbe05a97d5b6aba607f3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae6c26352ee4fcbe05a97d5b6aba607f3">◆ </a></span>ConnectionPool_setInitialConnections()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ConnectionPool_setInitialConnections </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int</td> <td class="paramname"><span class="paramname"><em>initialConnections</em></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">P</td><td>A ConnectionPool object </td></tr>
<tr><td class="paramname">initialConnections</td><td>The number of initial pool connections. It is a checked runtime error for initialConnections to be < 0 </td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="Connection_8h.html" title="A Connection represents a connection to a SQL database system.">Connection.h</a> </dd></dl>
</div>
</div>
<a id="aa6a2130831722010e89924aec17fe561" name="aa6a2130831722010e89924aec17fe561"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa6a2130831722010e89924aec17fe561">◆ </a></span>ConnectionPool_getInitialConnections()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int ConnectionPool_getInitialConnections </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Gets the number of initial connections in the pool. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The number of initial pool connections </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="Connection_8h.html" title="A Connection represents a connection to a SQL database system.">Connection.h</a> </dd></dl>
</div>
</div>
<a id="a68ac953c1bc1915b3ac6ae0b7b4c64a4" name="a68ac953c1bc1915b3ac6ae0b7b4c64a4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a68ac953c1bc1915b3ac6ae0b7b4c64a4">◆ </a></span>ConnectionPool_setMaxConnections()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ConnectionPool_setMaxConnections </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int</td> <td class="paramname"><span class="paramname"><em>maxConnections</em></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="#aeb9223e1addafed257e35e248c049097" title="Get a connection from the pool.">ConnectionPool_getConnection()</a> will return NULL on the next call.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
<tr><td class="paramname">maxConnections</td><td>The maximum number of connections this connection pool will create. It is a checked runtime error for maxConnections to be less than initialConnections. </td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="Connection_8h.html" title="A Connection represents a connection to a SQL database system.">Connection.h</a> </dd></dl>
</div>
</div>
<a id="a5edf7736ec825e4a1aafd4f7f85c24d5" name="a5edf7736ec825e4a1aafd4f7f85c24d5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5edf7736ec825e4a1aafd4f7f85c24d5">◆ </a></span>ConnectionPool_getMaxConnections()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int ConnectionPool_getMaxConnections </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Gets the maximum number of connections in the pool. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The maximum number of connections this pool will create. </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="Connection_8h.html" title="A Connection represents a connection to a SQL database system.">Connection.h</a> </dd></dl>
</div>
</div>
<a id="a143b4171cc03227b1bca5cd10e724bc5" name="a143b4171cc03227b1bca5cd10e724bc5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a143b4171cc03227b1bca5cd10e724bc5">◆ </a></span>ConnectionPool_setConnectionTimeout()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ConnectionPool_setConnectionTimeout </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int</td> <td class="paramname"><span class="paramname"><em>connectionTimeout</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Set the Connection inactive timeout value in seconds. </p>
<p>The method <a class="el" href="#a75e9b1e5c943a5bb76573a04268e496a" title="Reaps inactive connections in the pool.">ConnectionPool_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>
<p>The reaper thread, see <a class="el" href="#a756268df598fb93caeef570b775e6768" title="Customize the reaper thread behavior or disable it.">ConnectionPool_setReaper()</a>, will use this value when closing inactive Connections.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
<tr><td class="paramname">connectionTimeout</td><td>The number of <code>seconds</code> a Connection can be inactive (i.e., not in use) before the reaper closes the Connection. (value > 0) </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="ad2dabf50cf0b9710848eba40c58bf748" name="ad2dabf50cf0b9710848eba40c58bf748"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad2dabf50cf0b9710848eba40c58bf748">◆ </a></span>ConnectionPool_getConnectionTimeout()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int ConnectionPool_getConnectionTimeout </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Gets the connection timeout value. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The time an inactive Connection may live before it is closed </dd></dl>
</div>
</div>
<a id="a23b8c11de2c910a5ce75b008291ee22a" name="a23b8c11de2c910a5ce75b008291ee22a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a23b8c11de2c910a5ce75b008291ee22a">◆ </a></span>ConnectionPool_setAbortHandler()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ConnectionPool_setAbortHandler </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void(*</td> <td class="paramname"><span class="paramname"><em>abortHandler </em></span>)(const char *error) )</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> upon encountering a fatal error if ZBDEBUG is set; otherwise, exit(1) is called. This method provides clients with a means to close down execution gracefully. 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">P</td><td>A ConnectionPool object </td></tr>
<tr><td class="paramname">abortHandler</td><td>The handler function to call should a fatal error occur during processing. An explanatory error message is passed to the handler function in the string <code>error</code> </td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="Exception_8h.html" title="An Exception indicates an error condition from which recovery may be possible.">Exception.h</a> </dd></dl>
</div>
</div>
<a id="a756268df598fb93caeef570b775e6768" name="a756268df598fb93caeef570b775e6768"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a756268df598fb93caeef570b775e6768">◆ </a></span>ConnectionPool_setReaper()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ConnectionPool_setReaper </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int</td> <td class="paramname"><span class="paramname"><em>sweepInterval</em></span> )</td>
</tr>
</table>
</div><div class="memdoc">
<p>Customize the reaper thread behavior or disable 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 Connection is closed if its <code>connectionTimeout</code> has expired or if it fails the 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="#a8d7c529ccb99d0345e0c8524dba7281d" 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">P</td><td>A ConnectionPool object </td></tr>
<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="#a8d7c529ccb99d0345e0c8524dba7281d" title="Prepares the pool for active use.">ConnectionPool_start()</a>. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="a8d7c529ccb99d0345e0c8524dba7281d" name="a8d7c529ccb99d0345e0c8524dba7281d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8d7c529ccb99d0345e0c8524dba7281d">◆ </a></span>ConnectionPool_start()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ConnectionPool_start </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</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="#a756268df598fb93caeef570b775e6768" title="Customize the reaper thread behavior or disable it.">ConnectionPool_setReaper()</a>.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
</table>
</dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
<table class="exception">
<tr><td class="paramname">SQLException</td><td>If a database error occurs. </td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="SQLException_8h.html" title="Signals that an SQL specific exception has occurred.">SQLException.h</a> </dd></dl>
</div>
</div>
<a id="ac467a51ff4471989abbe07be1870072d" name="ac467a51ff4471989abbe07be1870072d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac467a51ff4471989abbe07be1870072d">◆ </a></span>ConnectionPool_stop()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ConnectionPool_stop </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</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="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="aeb9223e1addafed257e35e248c049097" name="aeb9223e1addafed257e35e248c049097"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aeb9223e1addafed257e35e248c049097">◆ </a></span>ConnectionPool_getConnection()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">Connection_T ConnectionPool_getConnection </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get a connection from the pool. </p>
<p>The returned Connection (if any) is guaranteed to be alive and connected to the database. NULL is returned if a database error occurred or if the pool is full and cannot return a new connection.</p>
<p>This example demonstrates how to check if the pool is full before attempting to get a connection, and how to handle potential errors:</p>
<div class="fragment"><div class="line"><span class="keywordflow">if</span> (<a class="code hl_function" href="#a1476a21ddfa994f43ffd14dc52b15b9b">ConnectionPool_isFull</a>(p)) {</div>
<div class="line"> <span class="comment">// Consider increasing pool size before trying to get a connection</span></div>
<div class="line"> <span class="comment">// ConnectionPool_setMaxConnections(p, ...)</span></div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line">Connection_T con = <a class="code hl_function" href="#aeb9223e1addafed257e35e248c049097">ConnectionPool_getConnection</a>(p);</div>
<div class="line"><span class="keywordflow">if</span> (!con) {</div>
<div class="line"> <span class="keywordflow">if</span> (<a class="code hl_function" href="#a1476a21ddfa994f43ffd14dc52b15b9b">ConnectionPool_isFull</a>(p)) {</div>
<div class="line"> <span class="comment">// Pool is full</span></div>
<div class="line"> fprintf(stderr, <span class="stringliteral">"Connection pool is full. Cannot acquire a new connection.\n"</span>);</div>
<div class="line"> } <span class="keywordflow">else</span> {</div>
<div class="line"> <span class="comment">// A database error occurred. This could be due</span></div>
<div class="line"> <span class="comment">// to network issues or database unavailability</span></div>
<div class="line"> fprintf(stderr, <span class="stringliteral">"Database error: Unable to acquire a connection.\n"</span>);</div>
<div class="line"> }</div>
<div class="line">} <span class="keywordflow">else</span> {</div>
<div class="line"> <span class="comment">// Use the connection...</span></div>
<div class="line">}</div>
<div class="ttc" id="aConnectionPool_8h_html_a1476a21ddfa994f43ffd14dc52b15b9b"><div class="ttname"><a href="#a1476a21ddfa994f43ffd14dc52b15b9b">ConnectionPool_isFull</a></div><div class="ttdeci">bool ConnectionPool_isFull(T P)</div><div class="ttdoc">Checks if the pool is full.</div></div>
</div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>A connection from the pool or NULL if a database error occurred. </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="Connection_8h.html" title="A Connection represents a connection to a SQL database system.">Connection.h</a> </dd>
<dd>
ConnectionPool_setMaxRetries(T P, int maxRetries) </dd></dl>
</div>
</div>
<a id="aa9a93750f071e29530e66e5b4bcda865" name="aa9a93750f071e29530e66e5b4bcda865"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa9a93750f071e29530e66e5b4bcda865">◆ </a></span>ConnectionPool_getConnectionOrException()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">Connection_T ConnectionPool_getConnectionOrException </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get a connection from the pool. </p>
<p>The returned Connection is guaranteed to be alive and connected to the database. The method <a class="el" href="#aeb9223e1addafed257e35e248c049097" title="Get a connection from the pool.">ConnectionPool_getConnection()</a> above is identical except it will return NULL if the pool is full or if a database error occured. This method will instead throw an SQLException in both cases with an appropriate error message.</p>
<p>This example demonstrates how to get a connection, and how to handle potential errors:</p>
<div class="fragment"><div class="line">Connection_T con = NULL;</div>
<div class="line"><a class="code hl_define" href="Exception_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a></div>
<div class="line">{</div>
<div class="line"> con = <a class="code hl_function" href="#aa9a93750f071e29530e66e5b4bcda865">ConnectionPool_getConnectionOrException</a>(p);</div>
<div class="line"> <span class="comment">// Use the connection...</span></div>
<div class="line">}</div>
<div class="line"><a class="code hl_define" href="Exception_8h.html#a0a70ee0cbf5b1738be4c9463c529ce72">ELSE</a></div>
<div class="line">{</div>
<div class="line"> <span class="comment">// The error message in Exception_frame.message will specify</span></div>
<div class="line"> <span class="comment">// if the pool was full or the database error that occured</span></div>
<div class="line"> fprintf(stderr, <span class="stringliteral">"Error: %s\n"</span>, Exception_frame.message);</div>
<div class="line">}</div>
<div class="line"><a class="code hl_define" href="Exception_8h.html#a0e2a75478cd44f1666a6aca626c5c50b">FINALLY</a></div>
<div class="line">{</div>
<div class="line"> <span class="keywordflow">if</span> (con) <a class="code hl_function" href="Connection_8h.html#aac4c939875fb240528435d486b484a7f">Connection_close</a>(con);</div>
<div class="line">}</div>
<div class="line"><a class="code hl_define" href="Exception_8h.html#ae6628ac788ad213363b89dba9868420b">END_TRY</a>;</div>
<div class="ttc" id="aConnectionPool_8h_html_aa9a93750f071e29530e66e5b4bcda865"><div class="ttname"><a href="#aa9a93750f071e29530e66e5b4bcda865">ConnectionPool_getConnectionOrException</a></div><div class="ttdeci">Connection_T ConnectionPool_getConnectionOrException(T P)</div><div class="ttdoc">Get a connection from the pool.</div></div>
<div class="ttc" id="aException_8h_html_a0a70ee0cbf5b1738be4c9463c529ce72"><div class="ttname"><a href="Exception_8h.html#a0a70ee0cbf5b1738be4c9463c529ce72">ELSE</a></div><div class="ttdeci">#define ELSE</div><div class="ttdoc">Defines a block containing code for handling any exception thrown in the TRY block.</div><div class="ttdef"><b>Definition</b> Exception.h:286</div></div>
<div class="ttc" id="aException_8h_html_a0e2a75478cd44f1666a6aca626c5c50b"><div class="ttname"><a href="Exception_8h.html#a0e2a75478cd44f1666a6aca626c5c50b">FINALLY</a></div><div class="ttdeci">#define FINALLY</div><div class="ttdoc">Defines a block of code that is subsequently executed whether an exception is thrown or not.</div><div class="ttdef"><b>Definition</b> Exception.h:297</div></div>
<div class="ttc" id="aException_8h_html_ad2746371528bdf15c3910b7bf217dac0"><div class="ttname"><a href="Exception_8h.html#ad2746371528bdf15c3910b7bf217dac0">TRY</a></div><div class="ttdeci">#define TRY</div><div class="ttdoc">Defines a block of code that can potentially throw an exception.</div><div class="ttdef"><b>Definition</b> Exception.h:258</div></div>
<div class="ttc" id="aException_8h_html_ae6628ac788ad213363b89dba9868420b"><div class="ttname"><a href="Exception_8h.html#ae6628ac788ad213363b89dba9868420b">END_TRY</a></div><div class="ttdeci">#define END_TRY</div><div class="ttdoc">Ends a TRY-CATCH block.</div><div class="ttdef"><b>Definition</b> Exception.h:308</div></div>
</div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>A connection from the pool </dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
<table class="exception">
<tr><td class="paramname">SQLException</td><td>If a database connection cannot be obtained. The error message is available in Exception_frame.message </td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="Connection_8h.html" title="A Connection represents a connection to a SQL database system.">Connection.h</a> </dd></dl>
</div>
</div>
<a id="a5d1f04dc0ae5fc42707dfd934f681c4a" name="a5d1f04dc0ae5fc42707dfd934f681c4a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5d1f04dc0ae5fc42707dfd934f681c4a">◆ </a></span>ConnectionPool_returnConnection()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ConnectionPool_returnConnection </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">Connection_T</td> <td class="paramname"><span class="paramname"><em>connection</em></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="Connection_8h.html#aac4c939875fb240528435d486b484a7f" 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 Connection after this method is called.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
<tr><td class="paramname">connection</td><td>A Connection object </td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="Connection_8h.html" title="A Connection represents a connection to a SQL database system.">Connection.h</a> </dd></dl>
</div>
</div>
<a id="a75e9b1e5c943a5bb76573a04268e496a" name="a75e9b1e5c943a5bb76573a04268e496a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a75e9b1e5c943a5bb76573a04268e496a">◆ </a></span>ConnectionPool_reapConnections()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int ConnectionPool_reapConnections </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Reaps inactive connections in the pool. </p>
<p>An inactive Connection is closed if and only if its <code>connectionTimeout</code> has expired <em>or</em> if the Connection failed the ping test against the database. Active Connections are <em>not</em> closed by this method.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The number of Connections that were closed </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="#a143b4171cc03227b1bca5cd10e724bc5" title="Set the Connection inactive timeout value in seconds.">ConnectionPool_setConnectionTimeout</a> </dd>
<dd>
<a class="el" href="#ae6c26352ee4fcbe05a97d5b6aba607f3" title="Sets the number of initial connections in the pool.">ConnectionPool_setInitialConnections</a> </dd>
<dd>
<a class="el" href="Connection_8h.html#ac9b36e40636c83f577630de22266d860" title="Pings the database server to check if the connection is alive.">Connection_ping</a> </dd></dl>
</div>
</div>
<a id="a76aacfe23b7708d436347107aedf0d15" name="a76aacfe23b7708d436347107aedf0d15"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a76aacfe23b7708d436347107aedf0d15">◆ </a></span>ConnectionPool_size()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int ConnectionPool_size </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Gets the current number of connections in the pool. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The total number of connections in the pool. </dd></dl>
</div>
</div>
<a id="a3c54f3a36f5dd94b2c622c01010df15f" name="a3c54f3a36f5dd94b2c622c01010df15f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3c54f3a36f5dd94b2c622c01010df15f">◆ </a></span>ConnectionPool_active()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int ConnectionPool_active </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Gets the number of active connections in the pool. </p>
<p>I.e., connections in current use by your application.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The number of active connections in the pool </dd></dl>
</div>
</div>
<a id="a1476a21ddfa994f43ffd14dc52b15b9b" name="a1476a21ddfa994f43ffd14dc52b15b9b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1476a21ddfa994f43ffd14dc52b15b9b">◆ </a></span>ConnectionPool_isFull()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool ConnectionPool_isFull </td>
<td>(</td>
<td class="paramtype"><a class="el" href="Connection_8h.html#a8dc1b239f8e305fbd1406ff041c89151">T</a></td> <td class="paramname"><span class="paramname"><em>P</em></span></td><td>)</td>
<td></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="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">P</td><td>A ConnectionPool object </td></tr>
</table>
</dd>
</dl>
<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="a7239f3b5265f6b10cb147fa9a6cc498d" name="a7239f3b5265f6b10cb147fa9a6cc498d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7239f3b5265f6b10cb147fa9a6cc498d">◆ </a></span>ConnectionPool_version()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const char * ConnectionPool_version </td>
<td>(</td>
<td class="paramtype">void</td> <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Gets the library version information. </p>
<dl class="section return"><dt>Returns</dt><dd>The library version information </dd></dl>
</div>
</div>
<h2 class="groupheader">Variable Documentation</h2>
<a id="a7886fb40d7187a54bb9a5ef8899616ce" name="a7886fb40d7187a54bb9a5ef8899616ce"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7886fb40d7187a54bb9a5ef8899616ce">◆ </a></span>ZBDEBUG</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">int ZBDEBUG</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">extern</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Library Debug flag. </p>
<p>If set to true, emit debug output </p>
</div>
</div>
</div><!-- contents -->
<p style="text-align:center;color:#808080;font-size:90%;margin:40px 0 20px 0;">
Copyright © <a href="https://tildeslash.com/">Tildeslash Ltd</a>. All
rights reserved.</p>
</body></html>
|