{"id":139,"date":"2014-06-24T16:05:51","date_gmt":"2014-06-25T01:05:51","guid":{"rendered":"http:\/\/blog.box.kr\/?p=139"},"modified":"2014-06-24T16:05:51","modified_gmt":"2014-06-25T01:05:51","slug":"jdbc-connection-pool-timeout-errors","status":"publish","type":"post","link":"https:\/\/blog.box.kr\/?p=139","title":{"rendered":"JDBC Connection Pool Timeout Errors"},"content":{"rendered":"<div id=\"node-101\" class=\"node \" style=\"color: #000000;\">\n<div class=\"node-content\">\n<p class=\"blog-author\" style=\"color: #444444;\">If the database server times out a connection, the connection pool on Tomcat side would not be aware of its disconnection.<\/p>\n<p style=\"color: #444444;\">If the database server times out a connection, the connection pool on Tomcat side would not be aware of its disconnection, and could throw the\u00a0following exception in Tomcat:<\/p>\n<div class=\"geshifilter\" style=\"color: #222222;\">\n<pre class=\"text geshifilter-text\">Caused by: com.ibm.db2.jcc.c.DisconnectException: A communication error has been detected.\nCommunication protocol being used: Reply.fill().\nCommunication API being used: InputStream.read().\nLocation where the error was detected: Read timed out.\nCommunication function detecting the error: *. Protocol specific error codes(s) TCP\/IP SOCKETS DB2ConnectionCorrelator: CCD3560A.K404.080507130918\nat com.ibm.db2.jcc.b.a.a(a.java:373)\nat com.ibm.db2.jcc.b.gb.b(gb.java:191)\nat com.ibm.db2.jcc.b.gb.c(gb.java:238)\nat com.ibm.db2.jcc.b.gb.c(gb.java:353)\nat com.ibm.db2.jcc.b.gb.v(gb.java:1362)<\/pre>\n<\/div>\n<p style=\"color: #444444;\">In order to prevent the exception, the connection pool can validate the connection.<\/p>\n<p style=\"color: #444444;\">In doing so, two attributes can be added to the JDBC resource, testOnBorrow and validationQuery respectively:<\/p>\n<div class=\"geshifilter\" style=\"color: #222222;\">\n<pre class=\"text geshifilter-text\">name=\"jdbc\/dsSos\"\nauth=\"Container\"\ntype=\"javax.sql.DataSource\"\nusername=\"******\"\npassword=\"*******\"\ndriverClassName=\"com.ibm.db2.jcc.DB2Driver\"\nfactory=\"org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory\"\nmaxIdle=\"2\"\nmaxWait=\"10000\"\nurl=\"jdbc:db2:\/\/mydbURL:50000\/MYDB\"\nmaxActive=\"15\"\nremoveAbandoned=\"true\"\nremoveAbandonedTimeout=\"300\"\ntestOnBorrow=\"true\"\nvalidationQuery=\"some sql...\"\nlogAbandoned=\"true\"\n\"some sql...\"<\/pre>\n<\/div>\n<p style=\"color: #444444;\">In the above example should be a valid SQL query that the connection pool will execute to ensure a live connection is returned to the application. The embedded query should be simple and efficient. For example:<\/p>\n<p style=\"color: #444444;\">For Oracle:<\/p>\n<div class=\"geshifilter\" style=\"color: #222222;\">\n<pre class=\"text geshifilter-text\">validationQuery=\"select 1 from dual\"<\/pre>\n<\/div>\n<p style=\"color: #444444;\">For MySQL:<\/p>\n<div class=\"geshifilter\" style=\"color: #222222;\">\n<pre class=\"text geshifilter-text\">validationQuery=\"select 1\"<\/pre>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>If the database server times out a connection, the connection pool on Tomcat side would not be aware of its disconnection. If the database server times out a connection, the connection pool on Tomcat side would not be aware of its disconnection, and could throw the\u00a0following exception in Tomcat: Caused by: com.ibm.db2.jcc.c.DisconnectException: A communication error has been detected. Communication protocol being used: Reply.fill(). Communication API being used: InputStream.read(). Location where the error was detected: Read timed out. Communication function detecting the error: *. Protocol specific error codes(s) TCP\/IP SOCKETS DB2ConnectionCorrelator: CCD3560A.K404.080507130918 at com.ibm.db2.jcc.b.a.a(a.java:373) at com.ibm.db2.jcc.b.gb.b(gb.java:191) at com.ibm.db2.jcc.b.gb.c(gb.java:238) at com.ibm.db2.jcc.b.gb.c(gb.java:353) at com.ibm.db2.jcc.b.gb.v(gb.java:1362) In order to prevent the exception, the connection pool can validate the connection. In doing so, two attributes can be added to the JDBC resource, testOnBorrow and validationQuery respectively: name=&#8221;jdbc\/dsSos&#8221; auth=&#8221;Container&#8221; type=&#8221;javax.sql.DataSource&#8221; username=&#8221;******&#8221; password=&#8221;*******&#8221; driverClassName=&#8221;com.ibm.db2.jcc.DB2Driver&#8221; factory=&#8221;org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory&#8221; maxIdle=&#8221;2&#8243; maxWait=&#8221;10000&#8243; url=&#8221;jdbc:db2:\/\/mydbURL:50000\/MYDB&#8221; maxActive=&#8221;15&#8243; removeAbandoned=&#8221;true&#8221; removeAbandonedTimeout=&#8221;300&#8243; testOnBorrow=&#8221;true&#8221; validationQuery=&#8221;some sql&#8230;&#8221; logAbandoned=&#8221;true&#8221; &#8220;some sql&#8230;&#8221; In the above example should be a valid SQL query that the connection pool will execute to ensure a live connection is returned to the application. The embedded query should be simple and efficient. For example: For Oracle: validationQuery=&#8221;select 1 from dual&#8221; For MySQL: validationQuery=&#8221;select 1&#8243;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"ngg_post_thumbnail":0,"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[25,7],"tags":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5q9Zn-2f","jetpack-related-posts":[{"id":133,"url":"https:\/\/blog.box.kr\/?p=133","url_meta":{"origin":139,"position":0},"title":"Tomcat JDBC Connection Pool configuration for production and development","date":"2014-06-24","format":false,"excerpt":"Tomcat JDBC Connection Pool configuration for production and development As mentioned in the post\u00a0Install Eclipse Kepler 64 bit on Windows 7 64 bit,\u00a0Podcastpedia.org\u00a0uses\u00a0Apache Tomcat 7\u00a0as application server. This post presents how the Tomcat JDBC Connection Pool is configured in development and production for\u00a0Podcastpedia.org. The used database is MySql. Contents\u00a0[hide] Production\u2026","rel":"","context":"In &quot;WAS, Servet Containers&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.codingpedia.org\/wp-content\/uploads\/2013\/08\/context-file-246x300.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":135,"url":"https:\/\/blog.box.kr\/?p=135","url_meta":{"origin":139,"position":1},"title":"Tomcat MySQL Connection &#8211; Using JDBC to Connect Tomcat to MySQL","date":"2014-06-24","format":false,"excerpt":"Tomcat MySQL Connection - Using JDBC to Connect Tomcat to MySQL Stumped by Tomcat JDBC connections? Can't get your head around MySQL drivers, connection pools, and JNDI resources? This article will guide you step-by-step through\u00a0connecting your MySQL database to Tomcat, in plain English. Along the way, we'll also cover setting\u2026","rel":"","context":"In &quot;WAS, Servet Containers&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":649,"url":"https:\/\/blog.box.kr\/?p=649","url_meta":{"origin":139,"position":2},"title":"[\ud38c]Tomcat7 tomcat-jdbc \uc124\uc815 &#8211; Broken pipe \uc5d0\ub7ec \ud68c\ud53c","date":"2015-04-05","format":false,"excerpt":"tomcat-jdbc\ub85c MySQL\uc5d0 \uc5f0\uacb0\ud55c \uacbd\uc6b0 \"java.net.SocketException: Broken pipe\" \uc5d0\ub7ec\uac00 \ubc1c\uc0dd\ud558\ub294 \uacbd\uc6b0\ub97c \uac00\ub054 \ubcfc \uc218 \uc788\ub2e4. \ub300\ubd80\ubd84\uc758 \uacbd\uc6b0 connection idle time\uc774 MySQL\uc5d0 \uc124\uc815\ub41c wait_timeout\uc744 \uc9c0\ub098\uc11c DB\uc5d0\uc11c \uc5f0\uacb0\uc744 \ub04a\uc740 \uac83\uc774\ub2e4. \uc774\ub97c \ubc29\uc9c0\ud558\ub824\uba74 connection\uc774 \uc77c\uc815 \uae30\uac04\ub3d9\uc548 \uc0ac\uc6a9\ub418\uc9c0 \uc54a\uc73c\uba74 close\ub418\ub3c4\ub85d \uc124\uc815\ud558\uac70\ub098 connection \ub300\uc5ec\uc2dc\uc5d0 connection\uc744 \uccb4\ud06c\ud558\ub3c4\ub85d \ud558\uba74 \ub41c\ub2e4. \uc124\uc815 1 - \uc77c\uc815 \uae30\uac04\ub3d9\uc548 \uc0ac\uc6a9\ub418\uc9c0 \uc54a\uc73c\uba74 connection\uc744\u2026","rel":"","context":"In &quot;\uae30\uc220\uc790\ub8cc&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":116,"url":"https:\/\/blog.box.kr\/?p=116","url_meta":{"origin":139,"position":3},"title":"MYSQL + TOMCAT \ub610\ub294 MYSQL\ub97c\u2026","date":"2014-06-18","format":false,"excerpt":"MYSQL + TOMCAT \ub610\ub294 MYSQL\ub97c \uc0ac\uc6a9\ud558\ub294 WEB \uac1c\ubc1c \uc2dc Connection POLL\uc774 \uc790\uc8fc \ub04a\uae30\ub294 \uc77c\uc774 \ube48\ubc88 \ud568.. \u00a0 \uc774\ub97c \ub9c9\uae30 \uc704\ud574 WAS Connection POOL \uc124\uc815\uc5d0 AutoReconnect = true\ub97c \uc918 \ubd24\uc9c0\ub9cc \uc18c\uc6a9 \uc5c6\uc74c.. \uc0dd\uac01 \ub05d\uc5d0 DB\uc758 connection time out\uc774 \uc5bc\ub9c8 \uc77c\uae4c \ud655\uc778 \ud574\ubcf4\ub2c8.. \u00a0 \uae30\ubcf8 \uac12\uc774.. 10\ucd08\uc784.. \uc820\uc7a5.. \uadf8\ub798\uc11c 600 \ucd08\ub85c \ub298\ub824\uc8fc.\u2026","rel":"","context":"In &quot;DB\uad00\ub828&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":678,"url":"https:\/\/blog.box.kr\/?p=678","url_meta":{"origin":139,"position":4},"title":"[Linux] Installing Tomcat 8 on a CentOS 7","date":"2015-04-13","format":false,"excerpt":"UPDATE SYSTEM First thing to do is to SSH to your CentOS 7 VPS, fire up a screen session and update your system using yum: ## screen -U -S tomcat8-centos7 ## yum update You may also want to install a text editor like nano or vim ## yum install vim\u2026","rel":"","context":"In &quot;\uae30\uc220\uc790\ub8cc&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":703,"url":"https:\/\/blog.box.kr\/?p=703","url_meta":{"origin":139,"position":5},"title":"NGINX , TOMCAT\uc73c\ub85c Virtual Host \uad6c\uc131 \ud558\uae30","date":"2015-04-15","format":false,"excerpt":"1. NGINX \uc758 \uae30\uc874 \ub514\ub809\ud1a0\ub9ac\uc778 \/etc\/nginx\/config.d\/ \ud558\uc704\uc5d0 \uc0ac\uc6a9\ud560 \ub3c4\uba54\uc77c \ubcc4\ub85c *.conf\uc744 \uc0dd\uc131 \ud55c\ub2e4. 2. \ub0b4\uc6a9\uc740 \ud558\uae30\uc640 \uac19\uc774 \ud55c\ub2e4. server { listen 80; server_name www.aaaa.com; location \/ { proxy_pass http:\/\/127.0.0.1:(\uc5f4\ub9acPORT \ubcf4\ud1b5 8080); } } 3. \ub9cc\uc57d \ud2b9\uc815 \ub514\ub809\ud1a0\ub9ac\ubcc4\ub85c TOMCAT\uc11c\ubc84\ub97c \ub098\ub20c\ub54c\ub294 \uc544\ub798\uc640 \uac19\uc774 \uc14b\ud305 \ud55c\ub2e4. server { listen 80; server_name www.aaaa.com; \u00a0\u2026","rel":"","context":"In &quot;\uae30\uc220\uc790\ub8cc&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/139"}],"collection":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=139"}],"version-history":[{"count":0,"href":"https:\/\/blog.box.kr\/index.php?rest_route=\/wp\/v2\/posts\/139\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.box.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}