{"id":2158,"date":"2017-09-07T11:47:12","date_gmt":"2017-09-07T03:47:12","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=2158"},"modified":"2017-09-07T11:47:12","modified_gmt":"2017-09-07T03:47:12","slug":"%e5%b8%b8%e7%94%a8%e6%95%b0%e6%8d%ae%e5%ba%93%e8%bf%9e%e6%8e%a5%e6%b1%a0-dbcp%e3%80%81c3p0%e3%80%81druid-%e9%85%8d%e7%bd%ae%e8%af%b4%e6%98%8e","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=2158","title":{"rendered":"\u5e38\u7528\u6570\u636e\u5e93\u8fde\u63a5\u6c60 (DBCP\u3001c3p0\u3001Druid) \u914d\u7f6e\u8bf4\u660e"},"content":{"rendered":"<div id=\"cnblogs_post_body\">\n<h1>1. \u5f15\u8a00<\/h1>\n<h2>1.1 \u5b9a\u4e49<\/h2>\n<p>\u6570\u636e\u5e93\u8fde\u63a5\u662f\u4e00\u79cd\u5173\u952e\u7684\u6709\u9650\u7684\u6602\u8d35\u7684\u8d44\u6e90\uff0c\u8fd9\u4e00\u70b9\u5728<a href=\"http:\/\/www.bing.com\/knows\/%E5%A4%9A%E7%94%A8%E6%88%B7\">\u591a\u7528\u6237<\/a>\u7684\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f53\u73b0\u5f97\u5c24\u4e3a\u7a81\u51fa\u3002\u5bf9\u6570\u636e\u5e93\u8fde\u63a5\u7684\u7ba1\u7406\u80fd\u663e\u8457\u5f71\u54cd\u5230\u6574\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7684\u4f38\u7f29\u6027\u548c<a href=\"http:\/\/www.bing.com\/knows\/%E5%81%A5%E5%A3%AE%E6%80%A7\">\u5065\u58ee\u6027<\/a>\uff0c\u5f71\u54cd\u5230\u7a0b\u5e8f\u7684\u6027\u80fd\u6307\u6807\u3002\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u6b63\u662f\u9488\u5bf9\u8fd9\u4e2a\u95ee\u9898\u63d0\u51fa\u6765\u7684\u3002<\/p>\n<p>\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u8d1f\u8d23\u5206\u914d\u3001\u7ba1\u7406\u548c\u91ca\u653e\u6570\u636e\u5e93\u8fde\u63a5\uff0c\u5b83\u5141\u8bb8\u5e94\u7528\u7a0b\u5e8f\u91cd\u590d\u4f7f\u7528\u4e00\u4e2a\u73b0\u6709\u7684\u6570\u636e\u5e93\u8fde\u63a5\uff0c\u800c\u4e0d\u662f\u518d\u91cd\u65b0\u5efa\u7acb\u4e00\u4e2a\uff1b\u91ca\u653e\u7a7a\u95f2\u65f6\u95f4\u8d85\u8fc7\u6700\u5927\u7a7a\u95f2\u65f6\u95f4\u7684\u6570\u636e\u5e93\u8fde\u63a5\u6765\u907f\u514d\u56e0\u4e3a\u6ca1\u6709\u91ca\u653e\u6570\u636e\u5e93\u8fde\u63a5\u800c\u5f15\u8d77\u7684\u6570\u636e\u5e93\u8fde\u63a5\u9057\u6f0f\u3002\u8fd9\u9879\u6280\u672f\u80fd\u660e\u663e\u63d0\u9ad8\u5bf9\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u6027\u80fd\u3002<\/p>\n<h2>1.2 \u53c2\u8003\u8d44\u6599<\/h2>\n<p>DBCP<\/p>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"http:\/\/commons.apache.org\/proper\/commons-dbcp\/download_dbcp.cgi\">http:\/\/commons.apache.org\/proper\/commons-dbcp\/download_dbcp.cgi<\/a><\/p>\n<p>\u76f8\u5173\u5c5e\u6027\u8bf4\u660e:\u00a0<a href=\"http:\/\/commons.apache.org\/proper\/commons-dbcp\/configuration.html\">http:\/\/commons.apache.org\/proper\/commons-dbcp\/configuration.html<\/a><\/p>\n<p>c3p0<\/p>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"http:\/\/sourceforge.net\/projects\/c3p0\/\">http:\/\/sourceforge.net\/projects\/c3p0\/<\/a><\/p>\n<p>\u76f8\u5173\u5c5e\u6027\u8bf4\u660e:\u00a0<a href=\"http:\/\/www.mchange.com\/projects\/c3p0\/\">http:\/\/www.mchange.com\/projects\/c3p0\/<\/a><\/p>\n<p>Druid<\/p>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"http:\/\/repo1.maven.org\/maven2\/com\/alibaba\/druid\/\">http:\/\/repo1.maven.org\/maven2\/com\/alibaba\/druid\/<\/a><\/p>\n<p>\u76f8\u5173\u5c5e\u6027\u8bf4\u660e:\u00a0<a href=\"https:\/\/github.com\/alibaba\/druid\/wiki\">https:\/\/github.com\/alibaba\/druid\/wiki<\/a><\/p>\n<p>&nbsp;<\/p>\n<h1>2. \u6570\u636e\u5e93\u8fde\u63a5\u6c60<\/h1>\n<h2>2.1 \u539f\u7406<\/h2>\n<p>\u8fde\u63a5\u6c60\u57fa\u672c\u7684\u601d\u60f3\u662f\u5728\u7cfb\u7edf\u521d\u59cb\u5316\u7684\u65f6\u5019\uff0c\u5c06\u6570\u636e\u5e93\u8fde\u63a5\u4f5c\u4e3a\u5bf9\u8c61\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u5f53\u7528\u6237\u9700\u8981\u8bbf\u95ee\u6570\u636e\u5e93\u65f6\uff0c\u5e76\u975e\u5efa\u7acb\u4e00\u4e2a\u65b0\u7684\u8fde\u63a5\uff0c\u800c\u662f\u4ece\u8fde\u63a5\u6c60\u4e2d\u53d6\u51fa\u4e00\u4e2a\u5df2\u5efa\u7acb\u7684\u7a7a\u95f2\u8fde\u63a5\u5bf9\u8c61\u3002\u4f7f\u7528\u5b8c\u6bd5\u540e\uff0c\u7528\u6237\u4e5f\u5e76\u975e\u5c06\u8fde\u63a5\u5173\u95ed\uff0c\u800c\u662f\u5c06\u8fde\u63a5\u653e\u56de\u8fde\u63a5\u6c60\u4e2d\uff0c\u4ee5\u4f9b\u4e0b\u4e00\u4e2a\u8bf7\u6c42\u8bbf\u95ee\u4f7f\u7528\u3002\u800c\u8fde\u63a5\u7684\u5efa\u7acb\u3001\u65ad\u5f00\u90fd\u7531\u8fde\u63a5\u6c60\u81ea\u8eab\u6765\u7ba1\u7406\u3002\u540c\u65f6\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u8fde\u63a5\u6c60\u7684\u53c2\u6570\u6765\u63a7\u5236\u8fde\u63a5\u6c60\u4e2d\u7684\u521d\u59cb\u8fde\u63a5\u6570\u3001\u8fde\u63a5\u7684\u4e0a\u4e0b\u9650\u6570\u4ee5\u53ca\u6bcf\u4e2a\u8fde\u63a5\u7684\u6700\u5927\u4f7f\u7528\u6b21\u6570\u3001\u6700\u5927\u7a7a\u95f2\u65f6\u95f4\u7b49\u7b49\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5176\u81ea\u8eab\u7684\u7ba1\u7406\u673a\u5236\u6765\u76d1\u89c6\u6570\u636e\u5e93\u8fde\u63a5\u7684\u6570\u91cf\u3001\u4f7f\u7528\u60c5\u51b5\u7b49\u3002<\/p>\n<h2>2.2 \u5e38\u89c1\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u53ca\u5176\u7279\u70b9<\/h2>\n<p>\u5728Java\u4e2d\u5f00\u6e90\u7684\u5e38\u7528\u7684\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u6709\u4ee5\u4e0b\u51e0\u79cd \uff1a<\/p>\n<p>1\uff09DBCP<\/p>\n<p>DBCP\u662f\u4e00\u4e2a\u4f9d\u8d56Jakarta commons-pool\u5bf9\u8c61\u6c60\u673a\u5236\u7684\u6570\u636e\u5e93\u8fde\u63a5\u6c60.DBCP\u53ef\u4ee5\u76f4\u63a5\u7684\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528\uff0cTomcat\u7684\u6570\u636e\u6e90\u4f7f\u7528\u7684\u5c31\u662fDBCP\u3002<\/p>\n<p>2\uff09c3p0<\/p>\n<p>c3p0\u662f\u4e00\u4e2a\u5f00\u653e\u6e90\u4ee3\u7801\u7684JDBC\u8fde\u63a5\u6c60\uff0c\u5b83\u5728lib\u76ee\u5f55\u4e2d\u4e0eHibernate\u4e00\u8d77\u53d1\u5e03,\u5305\u62ec\u4e86\u5b9e\u73b0jdbc3\u548cjdbc2\u6269\u5c55\u89c4\u8303\u8bf4\u660e\u7684Connection \u548cStatement \u6c60\u7684DataSources \u5bf9\u8c61\u3002<\/p>\n<p>3\uff09Druid<\/p>\n<p>\u963f\u91cc\u51fa\u54c1\uff0c\u6dd8\u5b9d\u548c\u652f\u4ed8\u5b9d\u4e13\u7528\u6570\u636e\u5e93\u8fde\u63a5\u6c60\uff0c\u4f46\u5b83\u4e0d\u4ec5\u4ec5\u662f\u4e00\u4e2a\u6570\u636e\u5e93\u8fde\u63a5\u6c60\uff0c\u5b83\u8fd8\u5305\u542b\u4e00\u4e2aProxyDriver\uff0c\u4e00\u7cfb\u5217\u5185\u7f6e\u7684JDBC\u7ec4\u4ef6\u5e93\uff0c\u4e00\u4e2aSQL Parser\u3002\u652f\u6301\u6240\u6709JDBC\u517c\u5bb9\u7684\u6570\u636e\u5e93\uff0c\u5305\u62ecOracle\u3001MySql\u3001Derby\u3001Postgresql\u3001SQL Server\u3001H2\u7b49\u7b49\u3002<\/p>\n<p>Druid\u9488\u5bf9Oracle\u548cMySql\u505a\u4e86\u7279\u522b\u4f18\u5316\uff0c\u6bd4\u5982Oracle\u7684PS Cache\u5185\u5b58\u5360\u7528\u4f18\u5316\uff0cMySql\u7684ping\u68c0\u6d4b\u4f18\u5316\u3002<\/p>\n<p>Druid\u63d0\u4f9b\u4e86MySql\u3001Oracle\u3001Postgresql\u3001SQL-92\u7684SQL\u7684\u5b8c\u6574\u652f\u6301\uff0c\u8fd9\u662f\u4e00\u4e2a\u624b\u5199\u7684\u9ad8\u6027\u80fdSQL Parser\uff0c\u652f\u6301Visitor\u6a21\u5f0f\uff0c\u4f7f\u5f97\u5206\u6790SQL\u7684\u62bd\u8c61\u8bed\u6cd5\u6811\u5f88\u65b9\u4fbf\u3002<\/p>\n<p>\u7b80\u5355SQL\u8bed\u53e5\u7528\u65f610\u5fae\u79d2\u4ee5\u5185\uff0c\u590d\u6742SQL\u7528\u65f630\u5fae\u79d2\u3002<\/p>\n<p>\u901a\u8fc7Druid\u63d0\u4f9b\u7684SQL Parser\u53ef\u4ee5\u5728JDBC\u5c42\u62e6\u622aSQL\u505a\u76f8\u5e94\u5904\u7406\uff0c\u6bd4\u5982\u8bf4\u5206\u5e93\u5206\u8868\u3001\u5ba1\u8ba1\u7b49\u3002Druid\u9632\u5fa1SQL\u6ce8\u5165\u653b\u51fb\u7684WallFilter\u5c31\u662f\u901a\u8fc7Druid\u7684SQL Parser\u5206\u6790\u8bed\u4e49\u5b9e\u73b0\u7684\u3002<\/p>\n<h1>3. \u4e3b\u8981\u914d\u7f6e\u8bf4\u660e<\/h1>\n<p>\u8fde\u63a5\u6c60\u914d\u7f6e\u5927\u4f53\u53ef\u4ee5\u5206\u4e3a\u57fa\u672c\u914d\u7f6e\u3001\u5173\u952e\u914d\u7f6e\u3001\u6027\u80fd\u914d\u7f6e\u7b49\u4e3b\u8981\u914d\u7f6e\u3002<\/p>\n<h2>3.1 \u57fa\u672c\u914d\u7f6e<\/h2>\n<p>\u57fa\u672c\u914d\u7f6e\u662f\u6307\u8fde\u63a5\u6c60\u8fdb\u884c\u6570\u636e\u5e93\u8fde\u63a5\u7684\u56db\u4e2a\u57fa\u672c\u5fc5\u9700\u914d\u7f6e\uff1a<\/p>\n<p>\u4f20\u9012\u7ed9JDBC\u9a71\u52a8\u7684\u7528\u4e8e\u8fde\u63a5\u6570\u636e\u5e93\u7684\u7528\u6237\u540d\u3001\u5bc6\u7801\u3001URL\u4ee5\u53ca\u9a71\u52a8\u7c7b\u540d\u3002<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"155\"><\/td>\n<td valign=\"top\" width=\"155\"><strong>DBCP<\/strong><\/td>\n<td valign=\"top\" width=\"155\"><strong>c3p0<\/strong><\/td>\n<td valign=\"top\" width=\"155\"><strong>Druid<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\"><strong>\u7528\u6237\u540d<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">username<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">user<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">username<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\"><strong>\u5bc6\u7801<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">password<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">password<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">password<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\"><strong>URL<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">url<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">jdbcUrl<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">jdbcUrl<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\"><strong>\u9a71\u52a8\u7c7b\u540d<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">driverClassName<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">driverClass<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">driverClassName<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6ce8:\u5728Druid\u8fde\u63a5\u6c60\u7684\u914d\u7f6e\u4e2d\uff0cdriverClassName\u53ef\u914d\u53ef\u4e0d\u914d\uff0c\u5982\u679c\u4e0d\u914d\u7f6e\u4f1a\u6839\u636eurl\u81ea\u52a8\u8bc6\u522bdbType(\u6570\u636e\u5e93\u7c7b\u578b)\uff0c\u7136\u540e\u9009\u62e9\u76f8\u5e94\u7684driverClassName\u3002<\/p>\n<h2>3.2 \u5173\u952e\u914d\u7f6e<\/h2>\n<p>\u4e3a\u4e86\u53d1\u6325\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u7684\u4f5c\u7528\uff0c\u5728\u521d\u59cb\u5316\u65f6\u5c06\u521b\u5efa\u4e00\u5b9a\u6570\u91cf\u7684\u6570\u636e\u5e93\u8fde\u63a5\u653e\u5230\u8fde\u63a5\u6c60\u4e2d\uff0c\u8fd9\u4e9b\u6570\u636e\u5e93\u8fde\u63a5\u7684\u6570\u91cf\u662f\u7531\u6700\u5c0f\u6570\u636e\u5e93\u8fde\u63a5\u6570\u6765\u8bbe\u5b9a\u7684\u3002\u65e0\u8bba\u8fd9\u4e9b\u6570\u636e\u5e93\u8fde\u63a5\u662f\u5426\u88ab\u4f7f\u7528\uff0c\u8fde\u63a5\u6c60\u90fd\u5c06\u4e00\u76f4\u4fdd\u8bc1\u81f3\u5c11\u62e5\u6709\u8fd9\u4e48\u591a\u7684\u8fde\u63a5\u6570\u91cf\u3002\u8fde\u63a5\u6c60\u7684\u6700\u5927\u6570\u636e\u5e93\u8fde\u63a5\u6570\u91cf\u9650\u5b9a\u4e86\u8fd9\u4e2a\u8fde\u63a5\u6c60\u80fd\u5360\u6709\u7684\u6700\u5927\u8fde\u63a5\u6570\uff0c\u5f53\u5e94\u7528\u7a0b\u5e8f\u5411\u8fde\u63a5\u6c60\u8bf7\u6c42\u7684\u8fde\u63a5\u6570\u8d85\u8fc7\u6700\u5927\u8fde\u63a5\u6570\u91cf\u65f6\uff0c\u8fd9\u4e9b\u8bf7\u6c42\u5c06\u88ab\u52a0\u5165\u5230\u7b49\u5f85\u961f\u5217\u4e2d\u3002<\/p>\n<p><strong>\u6700\u5c0f\u8fde\u63a5\u6570<\/strong>:<\/p>\n<p>\u662f\u6570\u636e\u5e93\u4e00\u76f4\u4fdd\u6301\u7684\u6570\u636e\u5e93\u8fde\u63a5\u6570\uff0c\u6240\u4ee5\u5982\u679c\u5e94\u7528\u7a0b\u5e8f\u5bf9\u6570\u636e\u5e93\u8fde\u63a5\u7684\u4f7f\u7528\u91cf\u4e0d\u5927\uff0c\u5c06\u6709\u5927\u91cf\u7684\u6570\u636e\u5e93\u8d44\u6e90\u88ab\u6d6a\u8d39\u3002<\/p>\n<p><strong>\u521d\u59cb\u5316\u8fde\u63a5\u6570\uff1a<\/strong><\/p>\n<p>\u8fde\u63a5\u6c60\u542f\u52a8\u65f6\u521b\u5efa\u7684\u521d\u59cb\u5316\u6570\u636e\u5e93\u8fde\u63a5\u6570\u91cf\u3002<\/p>\n<p><strong>\u6700\u5927\u8fde\u63a5\u6570<\/strong>\uff1a<\/p>\n<p>\u662f\u8fde\u63a5\u6c60\u80fd\u7533\u8bf7\u7684\u6700\u5927\u8fde\u63a5\u6570\uff0c\u5982\u679c\u6570\u636e\u5e93\u8fde\u63a5\u8bf7\u6c42\u8d85\u8fc7\u6b64\u6570\uff0c\u540e\u9762\u7684\u6570\u636e\u5e93\u8fde\u63a5\u8bf7\u6c42\u88ab\u52a0\u5165\u5230\u7b49\u5f85\u961f\u5217\u4e2d\u3002<\/p>\n<p><strong>\u6700\u5927\u7b49\u5f85\u65f6\u95f4\uff1a<\/strong><\/p>\n<p>\u5f53\u6ca1\u6709\u53ef\u7528\u8fde\u63a5\u65f6\uff0c\u8fde\u63a5\u6c60\u7b49\u5f85\u8fde\u63a5\u88ab\u5f52\u8fd8\u7684\u6700\u5927\u65f6\u95f4\uff0c\u8d85\u8fc7\u65f6\u95f4\u5219\u629b\u51fa\u5f02\u5e38\uff0c\u53ef\u8bbe\u7f6e\u53c2\u6570\u4e3a0\u6216\u8005\u8d1f\u6570\u4f7f\u5f97\u65e0\u9650\u7b49\u5f85(\u6839\u636e\u4e0d\u540c\u8fde\u63a5\u6c60\u914d\u7f6e)\u3002<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\"><strong>DBCP<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\"><strong>c3p0<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\"><strong>Druid<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\"><strong>\u6700\u5c0f\u8fde\u63a5\u6570<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">minIdle(0)<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">minPoolSize(3)<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">minIdle(0)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\"><strong>\u521d\u59cb\u5316\u8fde\u63a5\u6570<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">initialSize(0)<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">initialPoolSize(3)<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">initialSize(0)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\"><strong>\u6700\u5927\u8fde\u63a5\u6570<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">maxTotal(8)<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">maxPoolSize(15)<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">maxActive(8)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\"><strong>\u6700\u5927\u7b49\u5f85\u65f6\u95f4<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">maxWaitMillis(\u6beb\u79d2)<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">maxIdleTime(0\u79d2)<\/p>\n<\/td>\n<td valign=\"top\" width=\"155\">\n<p align=\"left\">maxWait(\u6beb\u79d2)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6ce81:\u5728DBCP\u8fde\u63a5\u6c60\u7684\u914d\u7f6e\u4e2d\uff0c\u8fd8\u6709\u4e00\u4e2amaxIdle\u7684\u5c5e\u6027\uff0c\u8868\u793a\u6700\u5927\u7a7a\u95f2\u8fde\u63a5\u6570\uff0c\u8d85\u8fc7\u7684\u7a7a\u95f2\u8fde\u63a5\u5c06\u88ab\u91ca\u653e\uff0c\u9ed8\u8ba4\u503c\u4e3a8\u3002\u5bf9\u5e94\u7684\u8be5\u5c5e\u6027\u5728Druid\u8fde\u63a5\u6c60\u5df2\u4e0d\u518d\u4f7f\u7528\uff0c\u914d\u7f6e\u4e86\u4e5f\u6ca1\u6709\u6548\u679c\uff0cc3p0\u8fde\u63a5\u6c60\u5219\u6ca1\u6709\u5bf9\u5e94\u7684\u5c5e\u6027\u3002<\/p>\n<p>\u6ce82\uff1a\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u5728\u521d\u59cb\u5316\u7684\u65f6\u5019\u4f1a\u521b\u5efainitialSize\u4e2a\u8fde\u63a5\uff0c\u5f53\u6709\u6570\u636e\u5e93\u64cd\u4f5c\u65f6\uff0c\u4f1a\u4ece\u6c60\u4e2d\u53d6\u51fa\u4e00\u4e2a\u8fde\u63a5\u3002\u5982\u679c\u5f53\u524d\u6c60\u4e2d\u6b63\u5728\u4f7f\u7528\u7684\u8fde\u63a5\u6570\u7b49\u4e8emaxActive\uff0c\u5219\u4f1a\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\uff0c\u7b49\u5f85\u5176\u4ed6\u64cd\u4f5c\u91ca\u653e\u6389\u67d0\u4e00\u4e2a\u8fde\u63a5\uff0c\u5982\u679c\u8fd9\u4e2a\u7b49\u5f85\u65f6\u95f4\u8d85\u8fc7\u4e86maxWait\uff0c\u5219\u4f1a\u62a5\u9519\uff1b\u5982\u679c\u5f53\u524d\u6b63\u5728\u4f7f\u7528\u7684\u8fde\u63a5\u6570\u6ca1\u6709\u8fbe\u5230maxActive\uff0c\u5219\u5224\u65ad\u5f53\u524d\u662f\u5426\u7a7a\u95f2\u8fde\u63a5\uff0c\u5982\u679c\u6709\u5219\u76f4\u63a5\u4f7f\u7528\u7a7a\u95f2\u8fde\u63a5\uff0c\u5982\u679c\u6ca1\u6709\u5219\u65b0\u5efa\u7acb\u4e00\u4e2a\u8fde\u63a5\u3002\u5728\u8fde\u63a5\u4f7f\u7528\u5b8c\u6bd5\u540e\uff0c\u4e0d\u662f\u5c06\u5176\u7269\u7406\u8fde\u63a5\u5173\u95ed\uff0c\u800c\u662f\u5c06\u5176\u653e\u5165\u6c60\u4e2d\u7b49\u5f85\u5176\u4ed6\u64cd\u4f5c\u590d\u7528\u3002<\/p>\n<h2>3.3 \u6027\u80fd\u914d\u7f6e<\/h2>\n<p><strong>\u9884\u7f13\u5b58\u8bbe\u7f6e<\/strong>:<\/p>\n<p>\u5373\u662fPSCache\uff0cPSCache\u5bf9\u652f\u6301\u6e38\u6807\u7684\u6570\u636e\u5e93\u6027\u80fd\u63d0\u5347\u5de8\u5927\uff0c\u6bd4\u5982\u8bf4oracle\u3002JDBC\u7684\u6807\u51c6\u53c2\u6570\uff0c\u7528\u4ee5\u63a7\u5236\u6570\u636e\u6e90\u5185\u52a0\u8f7d\u7684PreparedStatements\u6570\u91cf\u3002\u4f46\u7531\u4e8e\u9884\u7f13\u5b58\u7684statements\u5c5e\u4e8e\u5355\u4e2aconnection\u800c\u4e0d\u662f\u6574\u4e2a\u8fde\u63a5\u6c60\uff0c\u6240\u4ee5\u8bbe\u7f6e\u8fd9\u4e2a\u53c2\u6570\u9700\u8981\u8003\u8651\u5230\u591a\u65b9\u9762\u7684\u56e0\u7d20\u3002<\/p>\n<p>\u5355\u4e2a\u8fde\u63a5\u62e5\u6709\u7684\u6700\u5927\u7f13\u5b58\u6570\uff1a\u8981\u542f\u7528PSCache\uff0c\u5fc5\u987b\u914d\u7f6e\u5927\u4e8e0\uff0c\u5f53\u5927\u4e8e0\u65f6\uff0cpoolPreparedStatements\u81ea\u52a8\u89e6\u53d1\u4fee\u6539\u4e3atrue\u3002\u5728Druid\u4e2d\uff0c\u4e0d\u4f1a\u5b58\u5728Oracle\u4e0bPSCache\u5360\u7528\u5185\u5b58\u8fc7\u591a\u7684\u95ee\u9898\uff0c\u53ef\u4ee5\u628a\u8fd9\u4e2a\u6570\u503c\u914d\u7f6e\u5927\u4e00\u4e9b\uff0c\u6bd4\u5982\u8bf4100<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"92\">\n<p align=\"left\">\n<\/td>\n<td valign=\"top\" width=\"216\">\n<p align=\"left\"><strong>DBCP<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"154\">\n<p align=\"left\"><strong>c3p0<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"157\">\n<p align=\"left\"><strong>Druid<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"92\">\n<p align=\"left\"><strong>\u5f00\u542f\u7f13\u5b58\u529f\u80fd<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"216\">\n<p align=\"left\">poolPreparedStatements<\/p>\n<\/td>\n<td valign=\"top\" width=\"154\">\n<p align=\"left\">maxStatements<\/p>\n<\/td>\n<td valign=\"top\" width=\"157\">\n<p align=\"left\">poolPreparedStatements<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"92\">\n<p align=\"left\"><strong>\u5355\u4e2a\u8fde\u63a5\u62e5\u6709\u7684\u6700\u5927\u7f13\u5b58\u6570<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"216\">\n<p align=\"left\">maxOpenPrepared-<\/p>\n<p align=\"left\">Statements<\/p>\n<\/td>\n<td valign=\"top\" width=\"154\">\n<p align=\"left\">maxStatementsPer-<\/p>\n<p align=\"left\">Connection<\/p>\n<\/td>\n<td valign=\"top\" width=\"157\">\n<p align=\"left\">maxOpenPrepared-<\/p>\n<p align=\"left\">Statements<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u8fde\u63a5\u6709\u6548\u6027\u68c0\u6d4b\u8bbe\u7f6e:<\/strong><\/p>\n<p>\u8fde\u63a5\u6c60\u5185\u90e8\u6709\u673a\u5236\u5224\u65ad\uff0c\u5982\u679c\u5f53\u524d\u7684\u603b\u7684\u8fde\u63a5\u6570\u5c11\u4e8eminiIdle\uff0c\u5219\u4f1a\u5efa\u7acb\u65b0\u7684\u7a7a\u95f2\u8fde\u63a5\uff0c\u4ee5\u4fdd\u8bc1\u8fde\u63a5\u6570\u5f97\u5230miniIdle\u3002\u5982\u679c\u5f53\u524d\u8fde\u63a5\u6c60\u4e2d\u67d0\u4e2a\u8fde\u63a5\u5728\u7a7a\u95f2\u4e86timeBetweenEvictionRunsMillis\u65f6\u95f4\u540e\u4efb\u7136\u6ca1\u6709\u4f7f\u7528\uff0c\u5219\u88ab\u7269\u7406\u6027\u7684\u5173\u95ed\u6389\u3002\u6709\u4e9b\u6570\u636e\u5e93\u8fde\u63a5\u7684\u65f6\u5019\u6709\u8d85\u65f6\u9650\u5236\uff08mysql\u8fde\u63a5\u57288\u5c0f\u65f6\u540e\u65ad\u5f00\uff09\uff0c\u6216\u8005\u7531\u4e8e\u7f51\u7edc\u4e2d\u65ad\u7b49\u539f\u56e0\uff0c\u8fde\u63a5\u6c60\u7684\u8fde\u63a5\u4f1a\u51fa\u73b0\u5931\u6548\u7684\u60c5\u51b5\uff0c\u8fd9\u65f6\u5019\u8bbe\u7f6e\u4e00\u4e2atestWhileIdle\u53c2\u6570\u4e3atrue\uff0c\u53ef\u4ee5\u4fdd\u8bc1\u8fde\u63a5\u6c60\u5185\u90e8\u5b9a\u65f6\u68c0\u6d4b\u8fde\u63a5\u7684\u53ef\u7528\u6027\uff0c\u4e0d\u53ef\u7528\u7684\u8fde\u63a5\u4f1a\u88ab\u629b\u5f03\u6216\u8005\u91cd\u5efa\uff0c\u6700\u5927\u60c5\u51b5\u7684\u4fdd\u8bc1\u4ece\u8fde\u63a5\u6c60\u4e2d\u5f97\u5230\u7684Connection\u5bf9\u8c61\u662f\u53ef\u7528\u7684\u3002\u5f53\u7136\uff0c\u4e3a\u4e86\u4fdd\u8bc1\u7edd\u5bf9\u7684\u53ef\u7528\u6027\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528testOnBorrow\u4e3atrue\uff08\u5373\u5728\u83b7\u53d6Connection\u5bf9\u8c61\u65f6\u68c0\u6d4b\u5176\u53ef\u7528\u6027\uff09\uff0c\u4e0d\u8fc7\u8fd9\u6837\u4f1a\u5f71\u54cd\u6027\u80fd\u3002<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"92\">\n<p align=\"left\">\n<\/td>\n<td valign=\"top\" width=\"198\">\n<p align=\"left\"><strong>DBCP<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"151\">\n<p align=\"left\"><strong>c3p0<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"177\">\n<p align=\"left\"><strong>Druid<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"92\">\n<p align=\"left\"><strong>\u7533\u8bf7\u8fde\u63a5\u68c0\u6d4b<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"198\">\n<p align=\"left\">testOnBorrow<\/p>\n<\/td>\n<td valign=\"top\" width=\"151\">\n<p align=\"left\">testConnectionOnCheckin<\/p>\n<\/td>\n<td valign=\"top\" width=\"177\">\n<p align=\"left\">testOnBorrow<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"92\">\n<p align=\"left\"><strong>\u662f\u5426\u8d85\u65f6\u68c0\u6d4b<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"198\">\n<p align=\"left\">testWhileIdle<\/p>\n<\/td>\n<td valign=\"top\" width=\"151\">\n<p align=\"left\">\n<\/td>\n<td valign=\"top\" width=\"177\">\n<p align=\"left\">testWhileIdle<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"92\">\n<p align=\"left\"><strong>\u7a7a\u95f2\u65f6\u95f4<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"198\">\n<p align=\"left\">timeBetweenEvictionRunsMillis<\/p>\n<\/td>\n<td valign=\"top\" width=\"151\">\n<p align=\"left\">idleConnectionTestPeriod<\/p>\n<\/td>\n<td valign=\"top\" width=\"177\">\n<p align=\"left\">timeBetweenEvictionRunsMillis<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"92\">\n<p align=\"left\"><strong>\u6821\u9a8c\u7528sql\u8bed\u53e5<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"198\">\n<p align=\"left\">validationQuery<\/p>\n<\/td>\n<td valign=\"top\" width=\"151\">\n<p align=\"left\">preferredTestQuery<\/p>\n<\/td>\n<td valign=\"top\" width=\"177\">\n<p align=\"left\">validationQuery<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"92\">\n<p align=\"left\"><strong>\u5f52\u8fd8\u8fde\u63a5\u68c0\u6d4b<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"198\">\n<p align=\"left\">testOnReturn<\/p>\n<\/td>\n<td valign=\"top\" width=\"151\">\n<p align=\"left\">testConnectionOnCheckout<\/p>\n<\/td>\n<td valign=\"top\" width=\"177\">\n<p align=\"left\">testOnReturn<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u8d85\u65f6\u8fde\u63a5\u5173\u95ed\u8bbe\u7f6e<\/strong>:<\/p>\n<p>removeAbandoned\u53c2\u6570\uff0c\u7528\u6765\u68c0\u6d4b\u5230\u5f53\u524d\u4f7f\u7528\u7684\u8fde\u63a5\u662f\u5426\u53d1\u751f\u4e86\u8fde\u63a5\u6cc4\u9732\uff0c\u6240\u4ee5\u5728\u4ee3\u7801\u5185\u90e8\u5c31\u5047\u5b9a\u5982\u679c\u4e00\u4e2a\u8fde\u63a5\u5efa\u7acb\u8fde\u63a5\u7684\u65f6\u95f4\u5f88\u957f\uff0c\u5219\u5c06\u5176\u8ba4\u5b9a\u4e3a\u6cc4\u9732\uff0c\u7ee7\u800c\u5f3a\u5236\u5c06\u5176\u5173\u95ed\u6389\u3002<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"116\">\n<p align=\"left\">\n<\/td>\n<td valign=\"top\" width=\"173\">\n<p align=\"left\"><strong>DBCP<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"157\">\n<p align=\"left\"><strong>c3p0<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"173\">\n<p align=\"left\"><strong>Druid<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"116\">\n<p align=\"left\"><strong>\u662f\u5426\u8d85\u65f6\u5173\u95ed\u8fde\u63a5<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"173\">\n<p align=\"left\">removeAbandoned<\/p>\n<\/td>\n<td valign=\"top\" width=\"157\">\n<p align=\"left\">breakAfterAcquireFailure<\/p>\n<\/td>\n<td valign=\"top\" width=\"173\">\n<p align=\"left\">removeAbandoned<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"116\">\n<p align=\"left\"><strong>\u8d85\u65f6\u65f6\u95f4<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"173\">\n<p align=\"left\">removeAbandonedTimeout<\/p>\n<\/td>\n<td valign=\"top\" width=\"157\">\n<p align=\"left\">checkoutTimeout<\/p>\n<\/td>\n<td valign=\"top\" width=\"173\">\n<p align=\"left\">removeAbandonedTimeout<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"116\">\n<p align=\"left\"><strong>\u662f\u5426\u8bb0\u5f55\u65e5\u5fd7<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"173\">\n<p align=\"left\">logAbandoned<\/p>\n<\/td>\n<td valign=\"top\" width=\"157\">\n<p align=\"left\">\n<\/td>\n<td valign=\"top\" width=\"173\">\n<p align=\"left\">logAbandoned<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>c3p0<\/strong><strong>\u91cd\u8fde\u8bbe\u7f6e:<\/strong><\/p>\n<p>\u8bbe\u7f6e\u83b7\u53d6\u8fde\u63a5\u5931\u8d25\u540e\uff0c\u662f\u5426\u91cd\u65b0\u8fde\u63a5\u4ee5\u53ca\u95f4\u9694\u65f6\u95f4\u3002<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"111\">\n<p align=\"left\">\n<\/td>\n<td valign=\"top\" width=\"142\">\n<p align=\"left\"><strong>DBCP<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"173\">\n<p align=\"left\"><strong>c3p0<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"192\">\n<p align=\"left\"><strong>Druid<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"111\">\n<p align=\"left\"><strong>\u91cd\u8fde\u6b21\u6570<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"142\">\n<p align=\"left\">\n<\/td>\n<td valign=\"top\" width=\"173\">\n<p align=\"left\">acquireRetryAttempts<\/p>\n<\/td>\n<td valign=\"top\" width=\"192\">\n<p align=\"left\">\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"111\">\n<p align=\"left\"><strong>\u95f4\u9694\u65f6\u95f4<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"142\">\n<p align=\"left\">\n<\/td>\n<td valign=\"top\" width=\"173\">\n<p align=\"left\">acquireRetryDelay<\/p>\n<\/td>\n<td valign=\"top\" width=\"192\">\n<p align=\"left\">\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>4. \u914d\u7f6e\u8be6\u89e3<\/h1>\n<h2>4.1 DBCP \u5c5e\u6027\u8bf4\u660e\u8868<\/h2>\n<table style=\"height: 6652px;\" border=\"1\" width=\"932\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>\u5c5e\u6027(Parameter)<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u9ed8\u8ba4\u503c(Default)<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u63cf\u8ff0(Description)<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>username<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u4f20\u9012\u7ed9<\/strong><strong>JDBC<\/strong><strong>\u9a71\u52a8\u7684\u7528\u4e8e\u5efa\u7acb\u8fde\u63a5\u7684\u7528\u6237\u540d<\/strong>(The connection username to be passed to our JDBC driver to establish a connection.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>password \u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u4f20\u9012\u7ed9<\/strong><strong>JDBC<\/strong><strong>\u9a71\u52a8\u7684\u7528\u4e8e\u5efa\u7acb\u8fde\u63a5\u7684\u5bc6\u7801<\/strong>(The connection password to be passed to our JDBC driver to establish a connection.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>url<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u4f20\u9012\u7ed9<\/strong><strong>JDBC<\/strong><strong>\u9a71\u52a8\u7684\u7528\u4e8e\u5efa\u7acb\u8fde\u63a5\u7684<\/strong><strong>URL<\/strong>(The connection URL to be passed to our JDBC driver to establish a connection.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>driverClassName<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u4f7f\u7528\u7684<\/strong><strong>JDBC<\/strong><strong>\u9a71\u52a8\u7684\u5b8c\u6574\u6709\u6548\u7684<\/strong><strong>java\u00a0<\/strong><strong>\u7c7b\u540d<\/strong>(The fully qualified Java class name of the JDBC driver to be used.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>defaultAutoCommit<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>driver default<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u8fde\u63a5\u6c60\u521b\u5efa\u7684\u8fde\u63a5\u7684\u9ed8\u8ba4\u7684<\/strong><strong>auto-commit<\/strong><strong>\u72b6\u6001<\/strong><strong>,<\/strong><strong>\u6ca1\u6709\u8bbe\u7f6e\u5219\u4e0d\u4f1a\u81ea\u52a8\u63d0\u4ea4<\/strong>(The default auto-commit state of connections created by this pool. If not set then the setAutoCommit method will not be called.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>initialSize<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u521d\u59cb\u5316\u8fde\u63a5<\/strong><strong>:<\/strong><strong>\u8fde\u63a5\u6c60\u542f\u52a8\u65f6\u521b\u5efa\u7684\u521d\u59cb\u5316\u8fde\u63a5\u6570\u91cf<\/strong>(The initial number of connections that are created when the pool is started.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>maxTotal<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>8<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6700\u5927\u6d3b\u52a8\u8fde\u63a5<\/strong><strong>:<\/strong><strong>\u8fde\u63a5\u6c60\u5728\u540c\u4e00\u65f6\u95f4\u80fd\u591f\u5206\u914d\u7684\u6700\u5927\u6d3b\u52a8\u8fde\u63a5\u7684\u6570\u91cf<\/strong><strong>,\u00a0<\/strong><strong>\u5982\u679c\u8bbe\u7f6e\u4e3a\u975e\u6b63\u6570\u5219\u8868\u793a\u4e0d\u9650\u5236<\/strong>(The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>maxIdle<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>8<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6700\u5927\u7a7a\u95f2\u8fde\u63a5<\/strong><strong>:<\/strong><strong>\u8fde\u63a5\u6c60\u4e2d\u5bb9\u8bb8\u4fdd\u6301\u7a7a\u95f2\u72b6\u6001\u7684\u6700\u5927\u8fde\u63a5\u6570\u91cf<\/strong><strong>,<\/strong><strong>\u8d85\u8fc7\u7684\u7a7a\u95f2\u8fde\u63a5\u5c06\u88ab\u91ca\u653e<\/strong><strong>,<\/strong><strong>\u5982\u679c\u8bbe\u7f6e\u4e3a\u8d1f\u6570\u8868\u793a\u4e0d\u9650\u5236<\/strong>(The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>minIdle<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6700\u5c0f\u7a7a\u95f2\u8fde\u63a5<\/strong><strong>:<\/strong><strong>\u8fde\u63a5\u6c60\u4e2d\u5bb9\u8bb8\u4fdd\u6301\u7a7a\u95f2\u72b6\u6001\u7684\u6700\u5c0f\u8fde\u63a5\u6570\u91cf<\/strong><strong>,<\/strong><strong>\u8d1f\u6570\u8868\u793a\u6ca1\u6709\u73b0\u5728<\/strong>(The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.)<\/td>\n<\/tr>\n<tr>\n<td colspan=\"3\" valign=\"top\" width=\"646\"><strong>\u6ce8\u610f<\/strong><strong>\uff1a\u5982\u679c\u5728\u67d0\u4e9b\u8d1f\u8f7d\u6bd4\u8f83\u5927\u7684\u7cfb\u7edf\u4e2d\u5c06<\/strong><strong>maxIdel<\/strong><strong>\u8bbe\u7f6e\u8fc7\u5c0f\u65f6\uff0c\u5f88\u53ef\u80fd\u4f1a\u51fa\u73b0\u8fde\u63a5\u5173\u95ed\u7684\u540c\u65f6\u65b0\u8fde\u63a5\u9a6c\u4e0a\u6253\u5f00\u7684\u60c5\u51b5<\/strong><strong>.<\/strong><strong>\u8fd9\u662f\u7531\u4e8e\u5173\u95ed\u8fde\u63a5\u7684\u7ebf\u7a0b\u6bd4\u6253\u5f00\u7684\u5feb\u5bfc\u81f4\u7684<\/strong><strong>.<\/strong><strong>\u6240\u4ee5\uff0c\u5bf9\u4e8e\u8fd9\u79cd\u7cfb\u7edf\u4e2d<\/strong><strong>,maxIdle<\/strong><strong>\u7684\u8bbe\u5b9a\u503c\u662f\u4e0d\u540c\u7684\u4f46\u662f\u901a\u5e38\u9996\u9009\u9ed8\u8ba4\u503c<\/strong><\/td>\n<\/tr>\n<tr>\n<td colspan=\"3\" valign=\"top\" width=\"646\"><strong>(NOTE: If maxIdle is set too low on heavily loaded systems it is possible you will see connections being closed and almost immediately new connections being opened. This is a result of the active threads momentarily closing connections faster than they are opening them, causing the number of idle connections to rise above maxIdle. The best value for maxIdle for heavily loaded system will vary but the default is a good starting point.)<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>maxWaitMillis<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>indefinitely<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6700\u5927\u7b49\u5f85\u65f6\u95f4<\/strong><strong>:<\/strong><strong>\u5f53\u6ca1\u6709\u53ef\u7528\u8fde\u63a5\u65f6<\/strong><strong>,<\/strong><strong>\u8fde\u63a5\u6c60\u7b49\u5f85\u8fde\u63a5\u88ab\u5f52\u8fd8\u7684\u6700\u5927\u65f6\u95f4<\/strong><strong>(<\/strong><strong>\u4ee5\u6beb\u79d2\u8ba1\u6570<\/strong><strong>),<\/strong><strong>\u8d85\u8fc7\u65f6\u95f4\u5219\u629b\u51fa\u5f02\u5e38<\/strong><strong>,<\/strong><strong>\u5982\u679c\u8bbe\u7f6e\u4e3a<\/strong><strong>-1<\/strong><strong>\u8868\u793a\u65e0\u9650\u7b49\u5f85<\/strong>(The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>validationQuery\u00a0\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>SQL<\/strong><strong>\u67e5\u8be2<\/strong><strong>,<\/strong><strong>\u7528\u6765\u9a8c\u8bc1\u4ece\u8fde\u63a5\u6c60\u53d6\u51fa\u7684\u8fde\u63a5<\/strong><strong>,<\/strong><strong>\u5728\u5c06\u8fde\u63a5\u8fd4\u56de\u7ed9\u8c03\u7528\u8005\u4e4b\u524d<\/strong><strong>.<\/strong><strong>\u5982\u679c\u6307\u5b9a<\/strong><strong>,<\/strong><strong>\u5219\u67e5\u8be2\u5fc5\u987b\u662f\u4e00\u4e2a<\/strong><strong>SQL SELECT<\/strong><strong>\u5e76\u4e14\u5fc5\u987b\u8fd4\u56de\u81f3\u5c11\u4e00\u884c\u8bb0\u5f55<\/strong>(The SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query MUST be an SQL SELECT statement that returns at least one row. If not specified, connections will be validation by calling the isValid() method.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>testOnCreate<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6307\u660e\u662f\u5426\u5728\u5efa\u7acb\u8fde\u63a5\u4e4b\u540e\u8fdb\u884c\u9a8c\u8bc1<\/strong><strong>,<\/strong><strong>\u5982\u679c\u9a8c\u8bc1\u5931\u8d25<\/strong><strong>,<\/strong><strong>\u5219\u5c1d\u8bd5\u91cd\u65b0\u5efa\u7acb\u8fde\u63a5<\/strong>(The indication of whether objects will be validated after creation. If the object fails to validate, the borrow attempt that triggered the object creation will fail.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>testOnBorrow<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>true<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6307\u660e\u662f\u5426\u5728\u4ece\u6c60\u4e2d\u53d6\u51fa\u8fde\u63a5\u524d\u8fdb\u884c\u68c0\u9a8c<\/strong><strong>,<\/strong><strong>\u5982\u679c\u68c0\u9a8c\u5931\u8d25<\/strong><strong>,<\/strong><strong>\u5219\u4ece\u6c60\u4e2d\u53bb\u9664\u8fde\u63a5\u5e76\u5c1d\u8bd5\u53d6\u51fa\u53e6\u4e00\u4e2a<\/strong><strong>.<\/strong>\u00a0<strong>\u6ce8\u610f<\/strong><strong>:\u00a0<\/strong><strong>\u8bbe\u7f6e\u4e3a<\/strong><strong>true<\/strong><strong>\u540e\u5982\u679c\u8981\u751f\u6548<\/strong><strong>,validationQuery<\/strong><strong>\u53c2\u6570\u5fc5\u987b\u8bbe\u7f6e\u4e3a\u975e\u7a7a\u5b57\u7b26\u4e32<\/strong>(The indication of whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>testOnReturn<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6307\u660e\u662f\u5426\u5728\u5f52\u8fd8\u5230\u6c60\u4e2d\u524d\u8fdb\u884c\u68c0\u9a8c<\/strong>(The indication of whether objects will be validated before being returned to the pool.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>testWhileIdle<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6307\u660e\u8fde\u63a5\u662f\u5426\u88ab\u7a7a\u95f2\u8fde\u63a5\u56de\u6536\u5668<\/strong><strong>(<\/strong><strong>\u5982\u679c\u6709<\/strong><strong>)<\/strong><strong>\u8fdb\u884c\u68c0\u9a8c<\/strong><strong>.<\/strong><strong>\u5982\u679c\u68c0\u6d4b\u5931\u8d25<\/strong><strong>,<\/strong><strong>\u5219\u8fde\u63a5\u5c06\u88ab\u4ece\u6c60\u4e2d\u53bb\u9664<\/strong><strong>.<\/strong>\u00a0<strong>\u6ce8\u610f<\/strong><strong>:\u00a0<\/strong><strong>\u8bbe\u7f6e\u4e3a<\/strong><strong>true<\/strong><strong>\u540e\u5982\u679c\u8981\u751f\u6548<\/strong><strong>,validationQuery<\/strong><strong>\u53c2\u6570\u5fc5\u987b\u8bbe\u7f6e\u4e3a\u975e\u7a7a\u5b57\u7b26\u4e32<\/strong>(The indication of whether objects will be validated by the idle object evictor (if any). If an object fails to validate, it will be dropped from the pool.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>timeBetweenEviction-<\/strong><\/p>\n<p><strong>RunsMillis<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>-1<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5728\u7a7a\u95f2\u8fde\u63a5\u56de\u6536\u5668\u7ebf\u7a0b\u8fd0\u884c\u671f\u95f4\u4f11\u7720\u7684\u65f6\u95f4\u503c<\/strong><strong>,<\/strong><strong>\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d<\/strong><strong>.<\/strong><strong>\u5982\u679c\u8bbe\u7f6e\u4e3a\u975e\u6b63\u6570<\/strong><strong>,<\/strong><strong>\u5219\u4e0d\u8fd0\u884c\u7a7a\u95f2\u8fde\u63a5\u56de\u6536\u5668\u7ebf\u7a0b<\/strong>(The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>numTestsPerEvictionRun<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>3<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5728\u6bcf\u6b21\u7a7a\u95f2\u8fde\u63a5\u56de\u6536\u5668\u7ebf\u7a0b<\/strong><strong>(<\/strong><strong>\u5982\u679c\u6709<\/strong><strong>)<\/strong><strong>\u8fd0\u884c\u65f6\u68c0\u67e5\u7684\u8fde\u63a5\u6570\u91cf<\/strong>(The number of objects to examine during each run of the idle object evictor thread (if any).)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>minEvictableIdleTime-Millis\u00a0<\/strong><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>1000*60*30<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u8fde\u63a5\u5728\u6c60\u4e2d\u4fdd\u6301\u7a7a\u95f2\u800c\u4e0d\u88ab\u7a7a\u95f2\u8fde\u63a5\u56de\u6536\u5668\u7ebf\u7a0b<\/strong><strong>(<\/strong><strong>\u5982\u679c\u6709<\/strong><strong>)<\/strong><strong>\u56de\u6536\u7684\u6700\u5c0f\u65f6\u95f4\u503c\uff0c\u5355\u4f4d\u6beb\u79d2<\/strong>(The minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any).)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>softMiniEvictableIdle- TimeMillis<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>-1<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u8bf4\u660e<\/strong>(The minimum amount of time a connection may sit idle in the pool before it is eligible for eviction by the idle connection evictor, with the extra condition that at least &#8220;minIdle&#8221; connections remain in the pool. When miniEvictableIdleTimeMillis is set to a positive value, miniEvictableIdleTimeMillis is examined first by the idle connection evictor &#8211; i.e. when idle connections are visited by the evictor, idle time is first compared against miniEvictableIdleTimeMillis (without considering the number of idle connections in the pool) and then against softMinEvictableIdleTimeMillis, including the minIdle constraint.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>maxConnLifetimeMillis<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>-1<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u8bf4\u660e<\/strong>(The maximum lifetime in milliseconds of a connection. After this time is exceeded the connection will fail the next activation, passivation or validation test. A value of zero or less means the connection has an infinite lifetime.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>logExpiredConnections<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>true<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u8bf4\u660e<\/strong>(Flag to log a message indicating that a connection is being closed by the pool due to maxConnLifetimeMillis exceeded. Set this property to false to suppress expired connection logging that is turned on by default.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>connectionInitSqls<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>null<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u8bf4\u660e<\/strong>(A Collection of SQL statements that will be used to initialize physical connections when they are first created. These statements are executed only once &#8211; when the configured connection factory creates the connection.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>info<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>true<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u8bf4\u660e<\/strong>(True means that borrowObject returns the most recently used (&#8220;last in&#8221;) connection in the pool (if there are idle connections available). False means that the pool behaves as a FIFO queue &#8211; connections are taken from the idle instance pool in the order that they are returned to the pool.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>poolPreparedState-ments<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5f00\u542f\u6c60\u7684<\/strong><strong>prepared statement\u00a0<\/strong><strong>\u6c60\u529f\u80fd<\/strong>(Enable prepared statement pooling for this pool.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>maxOpenPreparedState-ments\u00a0<\/strong><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>unlimited<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>statement<\/strong><strong>\u6c60\u80fd\u591f\u540c\u65f6\u5206\u914d\u7684\u6253\u5f00\u7684<\/strong><strong>statements<\/strong><strong>\u7684\u6700\u5927\u6570\u91cf<\/strong><strong>,\u00a0<\/strong><strong>\u5982\u679c\u8bbe\u7f6e\u4e3a<\/strong><strong>0<\/strong><strong>\u8868\u793a\u4e0d\u9650\u5236<\/strong>(The maximum number of open statements that can be allocated from the statement pool at the same time, or negative for no limit.)<\/td>\n<\/tr>\n<tr>\n<td colspan=\"3\" valign=\"top\" width=\"646\"><strong>NOTE<\/strong>\u00a0&#8211; Make sure your connection has some resources left for the other statements. Pooling PreparedStatements may keep their cursors open in the database, causing a connection to run out of cursors, especially if maxOpenPreparedStatements is left at the default (unlimited) and an application opens a large number of different PreparedStatements per connection. To avoid this problem, maxOpenPreparedStatements should be set to a value less than the maximum number of cursors that can be open on a Connection.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>accessToUnderlyingConnectionAllowed<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u63a7\u5236<\/strong><strong>PoolGuard<\/strong><strong>\u662f\u5426\u5bb9\u8bb8\u83b7\u53d6\u5e95\u5c42\u8fde\u63a5<\/strong>(Controls if the PoolGuard allows access to the underlying connection.)\u00a0<strong>\u9ed8\u8ba4<\/strong><strong>false<\/strong><strong>\u4e0d\u5f00\u542f<\/strong><strong>,\u00a0<\/strong><strong>\u8fd9\u662f\u4e00\u4e2a\u6709\u6f5c\u5728\u5371\u9669\u7684\u529f\u80fd<\/strong><strong>,\u00a0<\/strong><strong>\u4e0d\u9002\u5f53\u7684\u7f16\u7801\u4f1a\u9020\u6210\u4f24\u5bb3<\/strong><strong>.(<\/strong><strong>\u5173\u95ed\u5e95\u5c42\u8fde\u63a5\u6216\u8005\u5728\u5b88\u62a4\u8fde\u63a5\u5df2\u7ecf\u5173\u95ed\u7684\u60c5\u51b5\u4e0b\u7ee7\u7eed\u4f7f\u7528\u5b83<\/strong><strong>).<\/strong><strong>\u8bf7\u8c28\u614e\u4f7f\u7528<\/strong><strong>,<\/strong><strong>\u5e76\u4e14\u4ec5\u5f53\u9700\u8981\u76f4\u63a5\u8bbf\u95ee\u9a71\u52a8\u7684\u7279\u5b9a\u529f\u80fd\u65f6\u4f7f\u7528<\/strong><strong>.<\/strong><strong>\u6ce8\u610f<\/strong><strong>:\u00a0<\/strong><strong>\u4e0d\u8981\u5173\u95ed\u5e95\u5c42\u8fde\u63a5<\/strong><strong>,\u00a0<\/strong><strong>\u53ea\u80fd\u5173\u95ed\u524d\u9762\u7684\u90a3\u4e2a<\/strong><strong>.\u00a0<\/strong>Default is false, it is a potential dangerous operation and misbehaving programs can do harmful things. (closing the underlying or continue using it when the guarded connection is already closed) Be careful and only use when you need direct access to driver specific extensions. NOTE: Do not close the underlying connection, only the original one.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>removeAbandoned<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6807\u8bb0\u662f\u5426\u5220\u9664\u6cc4\u9732\u7684\u8fde\u63a5<\/strong><strong>,<\/strong><strong>\u5982\u679c\u4ed6\u4eec\u8d85\u8fc7\u4e86<\/strong><strong>removeAbandonedTimout<\/strong><strong>\u7684\u9650\u5236<\/strong><strong>.<\/strong><strong>\u5982\u679c\u8bbe\u7f6e\u4e3a<\/strong><strong>true,\u00a0<\/strong><strong>\u8fde\u63a5\u88ab\u8ba4\u4e3a\u662f\u88ab\u6cc4\u9732\u5e76\u4e14\u53ef\u4ee5\u88ab\u5220\u9664<\/strong><strong>,<\/strong><strong>\u5982\u679c\u7a7a\u95f2\u65f6\u95f4\u8d85\u8fc7<\/strong><strong>removeAbandonedTimeout.\u00a0<\/strong><strong>\u8bbe\u7f6e\u4e3a<\/strong><strong>true<\/strong><strong>\u53ef\u4ee5\u4e3a\u5199\u6cd5\u7cdf\u7cd5\u7684\u6ca1\u6709\u5173\u95ed\u8fde\u63a5\u7684\u7a0b\u5e8f\u4fee\u590d\u6570\u636e\u5e93\u8fde\u63a5<\/strong><strong>. (<\/strong>Flags to remove abandoned connections if they exceed the removeAbandonedTimout. A connection is considered abandoned and eligible for removal if it has not been used for longer than removeAbandonedTimeout. Setting one or both of these to true can recover db connections from poorly written applications which fail to close connections.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>removeAbandonedTimeout<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>300<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6cc4\u9732\u7684\u8fde\u63a5\u53ef\u4ee5\u88ab\u5220\u9664\u7684\u8d85\u65f6\u503c<\/strong><strong>,\u00a0<\/strong><strong>\u5355\u4f4d\u79d2<\/strong><strong>(<\/strong>Timeout in seconds before an abandoned connection can be removed.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>logAbandoned<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6807\u8bb0\u5f53<\/strong><strong>Statement<\/strong><strong>\u6216\u8fde\u63a5\u88ab\u6cc4\u9732\u65f6\u662f\u5426\u6253\u5370\u7a0b\u5e8f\u7684<\/strong><strong>stack traces<\/strong><strong>\u65e5\u5fd7\u3002\u88ab\u6cc4\u9732\u7684<\/strong><strong>Statements<\/strong><strong>\u548c\u8fde\u63a5\u7684\u65e5\u5fd7\u6dfb\u52a0\u5728\u6bcf\u4e2a\u8fde\u63a5\u6253\u5f00\u6216\u8005\u751f\u6210\u65b0\u7684<\/strong><strong>Statement,<\/strong><strong>\u56e0\u4e3a\u9700\u8981\u751f\u6210<\/strong><strong>stack trace<\/strong><strong>\u3002<\/strong><strong>(<\/strong>Flag to log stack traces for application code which abandoned a Statement or Connection. Logging of abandoned Statements and Connections adds overhead for every Connection open or new Statement because a stack trace has to be generated.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>abandonedUsageTracking<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5982\u679c\u4e3a<\/strong><strong>true,\u00a0<\/strong><strong>\u90a3\u4e48\u8fde\u63a5\u6c60\u4f1a\u8bb0\u5f55\u6bcf\u4e2a\u65b9\u6cd5\u8c03\u7528\u65f6\u5019\u7684\u5806\u6808\u4fe1\u606f\u4ee5\u53ca\u5e9f\u5f03\u8fde\u63a5\u7684\u8c03\u8bd5\u4fe1\u606f<\/strong><strong>(<\/strong>If true, the connection pool records a stack trace every time a method is called on a pooled connection and retains the most recent stack trace to aid debugging of abandoned connections. There is significant overhead added by setting this to true.)<\/td>\n<\/tr>\n<tr>\n<td colspan=\"3\" valign=\"top\" width=\"646\"><strong>\u6ce8<\/strong><strong>:<\/strong><strong>\u5982\u679c\u5f00\u542f<\/strong><strong>&#8220;removeAbandoned&#8221;,<\/strong><strong>\u90a3\u4e48\u8fde\u63a5\u5728\u88ab\u8ba4\u4e3a\u6cc4\u9732\u65f6\u53ef\u80fd\u88ab\u6c60\u56de\u6536<\/strong><strong>.\u00a0<\/strong><strong>\u8fd9\u4e2a\u673a\u5236\u5728<\/strong><strong>(getNumIdle() &lt; 2)and (getNumActive() &gt; getMaxActive() &#8211; 3)<\/strong><strong>\u65f6\u88ab\u89e6\u53d1<\/strong><strong>.\u00a0<\/strong><strong>\u4e3e\u4f8b\u5f53<\/strong><strong>maxActive=20,\u00a0<\/strong><strong>\u6d3b\u52a8\u8fde\u63a5\u4e3a<\/strong><strong>18,<\/strong><strong>\u7a7a\u95f2\u8fde\u63a5\u4e3a<\/strong><strong>1<\/strong><strong>\u65f6\u53ef\u4ee5\u89e6\u53d1<\/strong><strong>&#8220;removeAbandoned&#8221;.<\/strong><strong>\u4f46\u662f\u6d3b\u52a8\u8fde\u63a5\u53ea\u6709\u5728\u6ca1\u6709\u88ab\u4f7f\u7528\u7684\u65f6\u95f4\u8d85\u8fc7<\/strong><strong>&#8220;removeAbandonedTimeout&#8221;<\/strong><strong>\u65f6\u624d\u88ab\u5220\u9664<\/strong><strong>,<\/strong><strong>\u9ed8\u8ba4<\/strong><strong>300<\/strong><strong>\u79d2<\/strong><strong>.<\/strong><strong>\u5728<\/strong><strong>resultset<\/strong><strong>\u4e2d\u6e38\u5386\u4e0d\u88ab\u8ba1\u7b97\u4e3a\u88ab\u4f7f\u7528<\/strong><strong>.<\/strong><\/td>\n<\/tr>\n<tr>\n<td colspan=\"3\" valign=\"top\" width=\"646\">If you have enabled removeAbandonedOnMaintenance or removeAbandonedOnBorrow then it is possible that a connection is reclaimed by the pool because it is considered to be abandoned. This mechanism is triggered when (getNumIdle() &lt; 2) and (getNumActive() &gt; getMaxTotal() &#8211; 3) and removeAbandonedOnBorrow is true; or after eviction finishes and removeAbandonedOnMaintenance is true. For example, maxTotal=20 and 18 active connections and 1 idle connection would trigger removeAbandonedOnBorrow, but only the active connections that aren&#8217;t used for more then &#8220;removeAbandonedTimeout&#8221; seconds are removed (default 300 sec). Traversing a resultset doesn&#8217;t count as being used. Creating a Statement, PreparedStatement or CallableStatement or using one of these to execute a query (using one of the execute methods) resets the lastUsed property of the parent connection.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>4.2 C3P0\u00a0 \u5c5e\u6027\u8bf4\u660e\u8868<\/h2>\n<table style=\"height: 3513px;\" border=\"1\" width=\"937\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>\u5c5e\u6027(Parameter)<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u9ed8\u8ba4\u503c(Default)<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u63cf\u8ff0(Description)<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>user<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u540c<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>username<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>password \u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u540c<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>password<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>jdbcUrl<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u540c<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>jdbcUrl<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>driverClass<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u540c<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>driverClass<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>autoCommitOnClose<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u9ed8\u8ba4\u503c<\/strong><strong>false<\/strong><strong>\u8868\u793a\u56de\u6eda\u4efb\u4f55\u672a\u63d0\u4ea4\u7684\u4efb\u52a1<\/strong><strong>,<\/strong><strong>\u8bbe\u7f6e\u4e3a<\/strong><strong>true<\/strong><strong>\u5219\u5168\u90e8\u63d0\u4ea4<\/strong><strong>,<\/strong><strong>\u800c\u4e0d\u662f\u5728\u5173\u95ed\u8fde\u63a5\u4e4b\u524d\u56de\u6eda<\/strong><\/p>\n<p><strong>(C3P0&#8217;s default policy is to rollback any uncommitted, pending work.<\/strong>\u00a0<strong>Setting autoCommitOnClose to true causes uncommitted pending work to be committed, rather than rolled back on Connection close.)<\/strong><\/p>\n<p><strong>*<\/strong><strong>\u53c2\u89c1<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>defaultAutoCommit<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>initialPoolSize<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>3<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u521d\u59cb\u5316\u8fde\u63a5<\/strong><strong>:<\/strong><strong>\u8fde\u63a5\u6c60\u542f\u52a8\u65f6\u521b\u5efa\u7684\u521d\u59cb\u5316\u8fde\u63a5\u6570\u91cf<\/strong>(The initial number of connections that are created when the pool is started.<\/p>\n<p><strong>*<\/strong><strong>\u53c2\u89c1<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>initialSize<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>maxPoolSize<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>15<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u8fde\u63a5\u6c60\u4e2d\u4fdd\u7559\u7684\u6700\u5927\u8fde\u63a5\u6570<\/strong>(Maximum number of Connections a pool will maintain at any given time.)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>*<\/strong><strong>\u53c2\u89c1<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>maxIdle<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>minPoolSize<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>3<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u8fde\u63a5\u6c60\u4e2d\u4fdd\u7559\u7684\u6700\u5c0f\u8fde\u63a5\u6570<\/strong>(Minimum number of Connections a pool will maintain at any given time.)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>*<\/strong><strong>\u53c2\u89c1<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>maxIdle<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>maxIdleTime<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6700\u5927\u7b49\u5f85\u65f6\u95f4<\/strong><strong>:<\/strong><strong>\u5f53\u6ca1\u6709\u53ef\u7528\u8fde\u63a5\u65f6<\/strong><strong>,<\/strong><strong>\u8fde\u63a5\u6c60\u7b49\u5f85\u8fde\u63a5\u88ab\u5f52\u8fd8\u7684\u6700\u5927\u65f6\u95f4<\/strong><strong>(<\/strong><strong>\u4ee5\u79d2\u8ba1\u6570<\/strong><strong>),<\/strong><strong>\u8d85\u8fc7\u65f6\u95f4\u5219\u629b\u51fa\u5f02\u5e38<\/strong><strong>,<\/strong><strong>\u5982\u679c\u8bbe\u7f6e\u4e3a<\/strong><strong>0<\/strong><strong>\u8868\u793a\u65e0\u9650\u7b49\u5f85<\/strong>(Seconds a Connection can remain pooled but unused before being discarded. Zero means idle connections never expire.)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>*<\/strong><strong>\u53c2\u89c1<\/strong><strong>DBCP<\/strong><strong>\u4e2d<\/strong><strong>maxWaitMillis\u00a0<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>preferredTestQuery<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>null<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5b9a\u4e49\u6240\u6709\u8fde\u63a5\u6d4b\u8bd5\u90fd\u6267\u884c\u7684\u6d4b\u8bd5\u8bed\u53e5\u3002\u5728\u4f7f\u7528\u8fde\u63a5\u6d4b\u8bd5\u7684\u60c5\u51b5\u4e0b\u8fd9\u4e2a\u4e00\u663e\u8457\u63d0\u9ad8\u6d4b\u8bd5\u901f\u5ea6\u3002\u6ce8\u610f\uff1a\u6d4b\u8bd5\u7684\u8868\u5fc5\u987b\u5728\u521d\u59cb\u6570\u636e\u6e90\u7684\u65f6\u5019\u5c31\u5b58\u5728\u3002<\/strong>(Defines the query that will be executed for all connection tests, if the default ConnectionTester (or some other implementation of QueryConnectionTester, or better yet FullQueryConnectionTester) is being used. Defining a preferredTestQuery that will execute quickly in your database may dramatically speed up Connection tests.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>testConnectionOn- Checkin<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5982\u679c\u8bbe\u4e3a<\/strong><strong>true<\/strong><strong>\u90a3\u4e48\u5728\u53d6\u5f97\u8fde\u63a5\u7684\u540c\u65f6\u5c06\u6821\u9a8c\u8fde\u63a5\u7684\u6709\u6548\u6027\u3002<\/strong>(If true, an operation will be performed asynchronously at every connection checkin to verify that the connection is valid. Use in combination with idleConnectionTestPeriod for quite reliable, always asynchronous Connection testing.)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>*<\/strong><strong>\u53c2\u89c1<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>testOnBorrow<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>testConnectionOn- Checkout<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5982\u679c\u8bbe\u4e3a<\/strong><strong>true<\/strong><strong>\u90a3\u4e48\u5728\u6bcf\u4e2a<\/strong><strong>connection<\/strong><strong>\u63d0\u4ea4\u7684\u65f6\u5019\u90fd\u5c06\u6821\u9a8c\u5176\u6709\u6548\u6027<\/strong><strong>,<\/strong><strong>\u4f46\u662f\u8981\u786e\u4fdd\u914d\u7f6e\u7684<\/strong><strong>preferredTestQuery<\/strong><strong>\u7684\u6709\u6548\u6027<\/strong>(If true, an operation will be performed at every connection checkout to verify that the connection is valid. Be sure to set an efficient preferredTestQuery or automaticTestTable if you set this to true.) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>*<\/strong><strong>\u53c2\u89c1<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>testOnBorrow<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>idleConnectionTest- Period<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5982\u679c\u8bbe\u7f6e\u5927\u4e8e<\/strong><strong>0,<\/strong><strong>\u8868\u793a\u8fc7\u4e86\u591a\u5c11\u79d2\u68c0\u67e5\u4e00\u6b21\u7a7a\u95f2\u8fde\u63a5<\/strong><strong>,<\/strong><strong>\u7ed3\u5408<\/strong><strong>testConnectionOnCheckin<\/strong><strong>\u4ee5\u53ca<\/strong><strong>testConnectionOnCheckout<\/strong><strong>\u4f7f\u7528<\/strong>(If this is a number greater than 0, c3p0 will test all idle, pooled but unchecked-out connections, every this number of seconds.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>acquireRetryAttempts<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>30<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5b9a\u4e49\u5728\u4ece\u6570\u636e\u5e93\u83b7\u53d6\u65b0\u8fde\u63a5\u5931\u8d25\u540e\u91cd\u590d\u5c1d\u8bd5\u7684\u6b21\u6570<\/strong><strong>,\u00a0<\/strong><strong>\u5982\u679c\u5c0f\u4e8e<\/strong><strong>0<\/strong><strong>\u5219\u8868\u793a\u65e0\u9650\u5236\u7684\u8fde\u63a5\u3002<\/strong>(Defines how many times c3p0 will try to acquire a new Connection from the database before giving up. If this value is less than or equal to zero, c3p0 will keep trying to fetch a Connection indefinitely.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>acquireRetryDelay<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>1000<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u4e24\u6b21\u8fde\u63a5\u4e2d\u7684\u95f4\u9694\u65f6\u95f4\uff0c\u5355\u4f4d\u6beb\u79d2\u3002<\/strong>(Milliseconds, time c3p0 will wait between acquire attempts.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>breakAfterAcquire-<\/strong><\/p>\n<p><strong>Failure<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u83b7\u53d6\u8fde\u63a5\u5931\u8d25\u5c06\u4f1a\u5f15\u8d77\u6240\u6709\u7b49\u5f85\u8fde\u63a5\u6c60\u6765\u83b7\u53d6\u8fde\u63a5\u7684\u7ebf\u7a0b\u629b\u51fa\u5f02\u5e38\u3002\u4f46\u662f\u6570\u636e\u6e90\u4ecd\u6709\u6548\u4fdd\u7559\uff0c\u5e76\u5728\u4e0b\u6b21\u8c03\u7528<\/strong><strong>\u00a0getConnection()\u00a0<\/strong><strong>\u7684\u65f6\u5019\u7ee7\u7eed\u5c1d\u8bd5\u83b7\u53d6\u8fde\u63a5\u3002\u5982\u679c\u4e3a<\/strong><strong>\u00a0true<\/strong><strong>\uff0c\u90a3\u4e48\u5728\u5c1d\u8bd5\u83b7\u53d6\u8fde\u63a5\u5931\u8d25\u540e\u8be5\u6570\u636e\u6e90\u5c06\u58f0\u660e\u5df2\u65ad\u5f00\u5e76\u6c38\u4e45\u5173\u95ed\u3002<\/strong>(If true, a pooled DataSource will declare itself broken and be permanently closed if a Connection cannot be obtained from the database after making acquireRetryAttempts to acquire one. If false, failure to obtain a Connection will cause all Threads waiting for the pool to acquire a Connection to throw an Exception, but the DataSource will remain valid, and will attempt to acquire again following a call to getConnection().)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>checkoutTimeout<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5f53\u8fde\u63a5\u6c60\u7528\u5b8c\u65f6\u5ba2\u6237\u7aef\u8c03\u7528<\/strong><strong>\u00a0getConnection()\u00a0<\/strong><strong>\u540e\u7b49\u5f85\u83b7\u53d6\u65b0\u8fde\u63a5\u7684\u65f6\u95f4\uff0c\u6f6e\u6e7f\u540e\u5c06\u629b\u51fa<\/strong><strong>SQLException<\/strong><strong>\uff0c\u5982\u8bbe\u4e3a<\/strong><strong>0<\/strong><strong>\uff0c\u5219\u4e3a\u65e0\u9650\u671f\u7b49\u5f85\u3002\u5355\u4f4d\u6beb\u79d2\u3002<\/strong>(The number of milliseconds a client calling getConnection() will wait for a Connection to be checked-in or acquired when the pool is exhausted. Zero means wait indefinitely. Setting any positive value will cause the getConnection() call to time-out and break with an SQLException after the specified number of milliseconds.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>maxStatements<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u63a7\u5236\u6570\u636e\u6e90\u5185\u52a0\u8f7d\u7684<\/strong><strong>PreparedStatements<\/strong><strong>\u6570\u91cf<\/strong>(Enable prepared statement pooling for this pool.)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>maxStatementsPer- Connection<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5b9a\u4e49\u4e86\u8fde\u63a5\u6c60\u5185\u5355\u4e2a\u8fde\u63a5\u6240\u62e5\u6709\u7684\u6700\u5927\u7f13\u5b58<\/strong><strong>statements<\/strong><strong>\u6570<\/strong>(The maximum number of open statements that can be allocated from the statement pool at the same time, or negative for no limit.)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>4.3 DRUID \u5c5e\u6027\u8bf4\u660e\u8868<\/h2>\n<table style=\"height: 1681px;\" border=\"1\" width=\"1131\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>\u5c5e\u6027(Parameter)<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u9ed8\u8ba4\u503c(Default)<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u63cf\u8ff0(Description)<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>username<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u8fde\u63a5\u6570\u636e\u5e93\u7684\u7528\u6237\u540d<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>password \u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u8fde\u63a5\u6570\u636e\u5e93\u7684\u5bc6\u7801<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>jdbcUrl<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u540c<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>jdbcUrl<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>driverClassName<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u6839\u636eurl\u81ea\u52a8\u8bc6\u522b<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u8fd9\u4e00\u9879\u53ef\u914d\u53ef\u4e0d\u914d\uff0c\u5982\u679c\u4e0d\u914d\u7f6e<\/strong><strong>druid<\/strong><strong>\u4f1a\u6839\u636e<\/strong><strong>url<\/strong><strong>\u81ea\u52a8\u8bc6\u522b<\/strong><strong>dbType<\/strong><strong>\uff0c\u7136\u540e\u9009\u62e9\u76f8\u5e94\u7684<\/strong><strong>driverClassName<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>initialSize<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u521d\u59cb\u5316\u65f6\u5efa\u7acb\u7269\u7406\u8fde\u63a5\u7684\u4e2a\u6570\u3002\u521d\u59cb\u5316\u53d1\u751f\u5728\u663e\u793a\u8c03\u7528<\/strong><strong>init<\/strong><strong>\u65b9\u6cd5\uff0c\u6216\u8005\u7b2c\u4e00\u6b21<\/strong><strong>getConnection<\/strong><strong>\u65f6<\/strong><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 *<\/strong><strong>\u53c2\u89c1<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>initialSize<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>maxActive<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>8<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6700\u5927\u8fde\u63a5\u6c60\u6570\u91cf<\/strong>(Maximum number of Connections a pool will maintain at any given time.)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>*<\/strong><strong>\u53c2\u89c1<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>maxTotal<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>maxIdle<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>8<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5df2\u7ecf\u4e0d\u518d\u4f7f\u7528\uff0c\u914d\u7f6e\u4e86\u4e5f\u6ca1\u6548\u679c<\/strong><strong>\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/strong>\u00a0\u00a0\u00a0\u00a0\u00a0<strong>*<\/strong><strong>\u53c2\u89c1<\/strong><strong>DBCP<\/strong><strong>\u4e2d\u7684<\/strong><strong>maxIdle<\/strong><strong>\u5c5e\u6027<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>minIdle<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6700\u5c0f\u8fde\u63a5\u6c60\u6570\u91cf<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>maxWait<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u83b7\u53d6\u8fde\u63a5\u65f6\u6700\u5927\u7b49\u5f85\u65f6\u95f4\uff0c\u5355\u4f4d\u6beb\u79d2\u3002\u914d\u7f6e\u4e86<\/strong><strong>maxWait<\/strong><strong>\u4e4b\u540e\uff0c\u7f3a\u7701\u542f\u7528\u516c\u5e73\u9501\uff0c\u5e76\u53d1\u6548\u7387\u4f1a\u6709\u6240\u4e0b\u964d\uff0c\u5982\u679c\u9700\u8981\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e<\/strong><strong>useUnfairLock<\/strong><strong>\u5c5e\u6027\u4e3a<\/strong><strong>true<\/strong><strong>\u4f7f\u7528\u975e\u516c\u5e73\u9501\u3002<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>poolPreparedState- ments<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u662f\u5426\u7f13\u5b58<\/strong><strong>preparedStatement<\/strong><strong>\uff0c\u4e5f\u5c31\u662f<\/strong><strong>PSCache<\/strong><strong>\u3002<\/strong><strong>PSCache<\/strong><strong>\u5bf9\u652f\u6301\u6e38\u6807\u7684\u6570\u636e\u5e93\u6027\u80fd\u63d0\u5347\u5de8\u5927\uff0c\u6bd4\u5982\u8bf4<\/strong><strong>oracle<\/strong><strong>\u3002<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>maxOpenPrepared- Statements<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>-1<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u8981\u542f\u7528<\/strong><strong>PSCache<\/strong><strong>\uff0c\u5fc5\u987b\u914d\u7f6e\u5927\u4e8e<\/strong><strong>0<\/strong><strong>\uff0c\u5f53\u5927\u4e8e<\/strong><strong>0<\/strong><strong>\u65f6\uff0c<\/strong><strong>poolPreparedStatements<\/strong><strong>\u81ea\u52a8\u89e6\u53d1\u4fee\u6539\u4e3a<\/strong><strong>true<\/strong><strong>\u3002<\/strong><strong>\u00a0 \u00a0\u00a0\u00a0\u00a0<\/strong><strong>\u5728<\/strong><strong>Druid<\/strong><strong>\u4e2d\uff0c\u4e0d\u4f1a\u5b58\u5728<\/strong><strong>Oracle<\/strong><strong>\u4e0b<\/strong><strong>PSCache<\/strong><strong>\u5360\u7528\u5185\u5b58\u8fc7\u591a\u7684\u95ee\u9898\uff0c\u53ef\u4ee5\u628a\u8fd9\u4e2a\u6570\u503c\u914d\u7f6e\u5927\u4e00\u4e9b\uff0c\u6bd4\u5982\u8bf4<\/strong><strong>100<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>testOnBorrow<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>true<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u7533\u8bf7\u8fde\u63a5\u65f6\u6267\u884c<\/strong><strong>validationQuery<\/strong><strong>\u68c0\u6d4b\u8fde\u63a5\u662f\u5426\u6709\u6548\uff0c\u505a\u4e86\u8fd9\u4e2a\u914d\u7f6e\u4f1a\u964d\u4f4e\u6027\u80fd\u3002<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>testOnReturn<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5f52\u8fd8\u8fde\u63a5\u65f6\u6267\u884c<\/strong><strong>validationQuery<\/strong><strong>\u68c0\u6d4b\u8fde\u63a5\u662f\u5426\u6709\u6548\uff0c\u505a\u4e86\u8fd9\u4e2a\u914d\u7f6e\u4f1a\u964d\u4f4e\u6027\u80fd<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>testWhileIdle<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5efa\u8bae\u914d\u7f6e\u4e3a<\/strong><strong>true<\/strong><strong>\uff0c\u4e0d\u5f71\u54cd\u6027\u80fd\uff0c\u5e76\u4e14\u4fdd\u8bc1\u5b89\u5168\u6027\u3002\u7533\u8bf7\u8fde\u63a5\u7684\u65f6\u5019\u68c0\u6d4b\uff0c\u5982\u679c\u7a7a\u95f2\u65f6\u95f4\u5927\u4e8e<\/strong><strong>timeBetweenEvictionRunsMillis<\/strong><strong>\uff0c\u6267\u884c<\/strong><strong>validationQuery<\/strong><strong>\u68c0\u6d4b\u8fde\u63a5\u662f\u5426\u6709\u6548\u3002<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>validationQuery<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u7528\u6765\u68c0\u6d4b\u8fde\u63a5\u662f\u5426\u6709\u6548\u7684<\/strong><strong>sql<\/strong><strong>\uff0c\u8981\u6c42\u662f\u4e00\u4e2a\u67e5\u8be2\u8bed\u53e5\u3002\u5982\u679c<\/strong><strong>validationQuery<\/strong><strong>\u4e3a<\/strong><strong>null<\/strong><strong>\uff0c<\/strong><strong>testOnBorrow<\/strong><strong>\u3001<\/strong><strong>testOnReturn<\/strong><strong>\u3001<\/strong><strong>testWhileIdle<\/strong><strong>\u90fd\u4e0d\u4f1a\u5176\u4f5c\u7528\u3002\u5728<\/strong><strong>mysql<\/strong><strong>\u4e2d\u901a\u5e38\u4e3a<\/strong><strong>select &#8216;x&#8217;<\/strong><strong>\uff0c\u5728<\/strong><strong>oracle<\/strong><strong>\u4e2d\u901a\u5e38\u4e3a<\/strong><strong>select 1 from dual<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>timeBetweenEviction-RunsMillis<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>1) Destroy<\/strong><strong>\u7ebf\u7a0b\u4f1a\u68c0\u6d4b\u8fde\u63a5\u7684\u95f4\u9694\u65f6\u95f4<\/strong><strong>\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02) testWhileIdle<\/strong><strong>\u7684\u5224\u65ad\u4f9d\u636e<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>minEvictableIdle- TimeMillis<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>Destory<\/strong><strong>\u7ebf\u7a0b\u4e2d\u5982\u679c\u68c0\u6d4b\u5230\u5f53\u524d\u8fde\u63a5\u7684\u6700\u540e\u6d3b\u8dc3\u65f6\u95f4\u548c\u5f53\u524d\u65f6\u95f4\u7684\u5dee\u503c\u5927\u4e8e<\/strong><strong>minEvictableIdleTimeMillis<\/strong><strong>\uff0c\u5219\u5173\u95ed\u5f53\u524d\u8fde\u63a5\u3002<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>removeAbandoned<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5bf9\u4e8e\u5efa\u7acb\u65f6\u95f4\u8d85\u8fc7<\/strong><strong>removeAbandonedTimeout<\/strong><strong>\u7684\u8fde\u63a5\u5f3a\u5236\u5173\u95ed<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>removeAbandoned-Timeout<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6307\u5b9a\u8fde\u63a5\u5efa\u7acb\u591a\u957f\u65f6\u95f4\u5c31\u9700\u8981\u88ab\u5f3a\u5236\u5173\u95ed<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>logAbandoned<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>false<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u6307\u5b9a\u53d1\u751f<\/strong><strong>removeabandoned<\/strong><strong>\u7684\u65f6\u5019\uff0c\u662f\u5426\u8bb0\u5f55\u5f53\u524d\u7ebf\u7a0b\u7684\u5806\u6808\u4fe1\u606f\u5230\u65e5\u5fd7\u4e2d<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"182\"><strong>filters<\/strong><\/td>\n<td valign=\"top\" width=\"138\"><strong>\u00a0<\/strong><\/td>\n<td valign=\"top\" width=\"327\"><strong>\u5c5e\u6027\u7c7b\u578b\u662f\u5b57\u7b26\u4e32\uff0c\u901a\u8fc7\u522b\u540d\u7684\u65b9\u5f0f\u914d\u7f6e\u6269\u5c55\u63d2\u4ef6\uff0c\u5e38\u7528\u7684\u63d2\u4ef6\u6709\uff1a<\/strong><strong>\u00a01<\/strong><strong>\uff09\u76d1\u63a7\u7edf\u8ba1\u7528\u7684<\/strong><strong>filter:stat \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02<\/strong><strong>\uff09\u65e5\u5fd7\u7528\u7684<\/strong><strong>filter:log4j \u00a0\u00a03<\/strong><strong>\uff09\u9632\u5fa1<\/strong><strong>sql<\/strong><strong>\u6ce8\u5165\u7684<\/strong><strong>filter:wall<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div class=\"clear\"><\/div>\n<div id=\"blog_post_info_block\">\n<div id=\"BlogPostCategory\"><\/div>\n<div id=\"EntryTag\">\u8f6c\u81f3:http:\/\/www.cnblogs.com\/JavaSubin\/p\/5294721.html<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5f15\u8a00 1.1 \u5b9a\u4e49 \u6570\u636e\u5e93\u8fde\u63a5\u662f\u4e00\u79cd\u5173\u952e\u7684\u6709\u9650\u7684\u6602\u8d35\u7684\u8d44\u6e90\uff0c\u8fd9\u4e00\u70b9\u5728\u591a\u7528\u6237\u7684\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f53\u73b0\u5f97\u5c24\u4e3a\u7a81\u51fa [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[61],"tags":[],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2158"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2158"}],"version-history":[{"count":4,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2158\/revisions"}],"predecessor-version":[{"id":2162,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2158\/revisions\/2162"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}