{"id":4638,"date":"2015-04-26T20:10:41","date_gmt":"2015-04-26T12:10:41","guid":{"rendered":"http:\/\/rmohan.com\/?p=4638"},"modified":"2015-04-26T20:10:41","modified_gmt":"2015-04-26T12:10:41","slug":"setting-the-jdbc-connection-timeout-properties-through-wlst","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=4638","title":{"rendered":"Setting the JDBC Connection timeout properties through WLST"},"content":{"rendered":"<p>There are different timeout properties in JDBC connection, this post explain the approach to set some of the important timeout properties through WLST script.<\/p>\n<p><b>Inactive Connection Timeout:<\/b><br \/>\nThe number of inactive seconds on a reserved connection before WebLogic Server reclaims the connection and releases it back into the connection pool.<br \/>\nYou can use the Inactive Connection Timeout feature to reclaim leaked connections &#8211; connections that were not explicitly closed by the application.<\/p>\n<p><b>Connection Reserve Timeout:<\/b><br \/>\nThe number of seconds after which a call to reserve a connection from the connection pool will timeout.<br \/>\nWhen set to 0, a call will never timeout.<br \/>\nWhen set to -1, a call will timeout immediately.<\/p>\n<p><b>Statement Timeout:<\/b><br \/>\nThe time after which a statement currently being executed will time out.<br \/>\nA value of -1 disables this feature.<br \/>\nA value of 0 means that statements will not time out.<\/p>\n<div><\/div>\n<div><b>oracle.jdbc.ReadTimeout:<\/b><\/div>\n<div>The property oracle.jdbc.ReadTimeout helps to set read timeout while reading from the socket.<\/div>\n<div>oracle.net.READ_TIMEOUT for jdbc versions &lt; 10.1.0.5 oracle.jdbc.ReadTimeout for jdbc versions &gt;=10.1.0.5<\/p>\n<p><b>oracle.net.CONNECT_TIMEOUT:<\/b><br \/>\nThe property oracle.net.CONNECT_TIMEOUT helps to set the login time out in Oracle.<\/p>\n<div>\n<div><\/div>\n<div><b>SetJDBCTimeoutProperties.py<\/b><\/div>\n<p>def setJDBCTimeoutProperties():<br \/>\ndsName=&#8217;CRM6EAIReference&#8217;<br \/>\nedit()<br \/>\nstartEdit()<br \/>\n<span class=\"Apple-converted-space\">\u00a0<\/span><br \/>\nserver=&#8217;AdminServer&#8217;<br \/>\ncd(&#8220;Servers\/&#8221;+server)<br \/>\ntarget=cmo<br \/>\n<span class=\"Apple-converted-space\">\u00a0<\/span><br \/>\nprint &#8216;=========================================&#8217;<br \/>\nprint &#8216;Setting the timeout properties for DataSource&#8230;.&#8217;<br \/>\nprint &#8216;=========================================&#8217; \u00a0<span class=\"Apple-converted-space\">\u00a0<\/span><br \/>\n<span class=\"Apple-converted-space\">\u00a0<\/span><br \/>\ncd(&#8216;\/JDBCSystemResources\/&#8217;+dsName+&#8217;\/JDBCResource\/&#8217;+dsName+&#8217;\/JDBCDriverParams\/&#8217;+dsName+&#8217;\/Properties\/&#8217;+dsName)<br \/>\n#cmo.destroyProperty(getMBean(&#8216;\/JDBCSystemResources\/&#8217;+dsName+&#8217;\/JDBCResource\/&#8217;+dsName+&#8217;\/JDBCDriverParams\/&#8217;+dsName+&#8217;\/Properties\/&#8217;+dsName+&#8217;\/Properties\/oracle.net.CONNECT_TIMEOUT&#8217;))<br \/>\ncmo.createProperty(&#8216;oracle.net.CONNECT_TIMEOUT&#8217;)<\/p>\n<p>#cmo.destroyProperty(getMBean(&#8216;\/JDBCSystemResources\/&#8217;+dsName+&#8217;\/JDBCResource\/&#8217;+dsName+&#8217;\/JDBCDriverParams\/&#8217;+dsName+&#8217;\/Properties\/&#8217;+dsName+&#8217;\/Properties\/oracle.jdbc.ReadTimeout&#8217;))<br \/>\ncmo.createProperty(&#8216;oracle.jdbc.ReadTimeout&#8217;)<\/p>\n<p>cd(&#8216;\/JDBCSystemResources\/&#8217;+dsName+&#8217;\/JDBCResource\/&#8217;+dsName+&#8217;\/JDBCDriverParams\/&#8217;+dsName+&#8217;\/Properties\/&#8217;+dsName+&#8217;\/Properties\/oracle.net.CONNECT_TIMEOUT&#8217;)<br \/>\ncmo.setValue(&#8216;10000&#8217;)<\/p>\n<p>cd(&#8216;\/JDBCSystemResources\/&#8217;+dsName+&#8217;\/JDBCResource\/&#8217;+dsName+&#8217;\/JDBCDriverParams\/&#8217;+dsName+&#8217;\/Properties\/&#8217;+dsName+&#8217;\/Properties\/oracle.jdbc.ReadTimeout&#8217;)<br \/>\ncmo.setValue(&#8216;20000&#8217;)<\/p>\n<p>cd(&#8216;\/JDBCSystemResources\/&#8217;+dsName+&#8217;\/JDBCResource\/&#8217;+dsName+&#8217;\/JDBCConnectionPoolParams\/&#8217;+dsName)<br \/>\ncmo.setInactiveConnectionTimeoutSeconds(120)<\/p>\n<p>cd(&#8216;\/JDBCSystemResources\/&#8217;+dsName+&#8217;\/JDBCResource\/&#8217;+dsName+&#8217;\/JDBCConnectionPoolParams\/&#8217;+dsName)<br \/>\ncmo.setConnectionReserveTimeoutSeconds(30)<\/p>\n<p>cd(&#8216;\/JDBCSystemResources\/&#8217;+dsName+&#8217;\/JDBCResource\/&#8217;+dsName+&#8217;\/JDBCConnectionPoolParams\/&#8217;+dsName)<br \/>\ncmo.setStatementTimeout(120)<\/p>\n<p>save()<br \/>\nactivate()<\/p>\n<p>print &#8216;Timeout settings for the datasource &#8216;+dsName+&#8217; has been completed&#8217;<br \/>\n<span class=\"Apple-converted-space\">\u00a0<\/span><br \/>\n<span class=\"Apple-converted-space\">\u00a0<\/span><br \/>\ndef main():<br \/>\n<span class=\"Apple-converted-space\">\u00a0<\/span><br \/>\nadminURL=&#8217;t3:\/\/localhost:8000&#8242;<br \/>\nadminUserName=&#8217;weblogic&#8217;<br \/>\nadminPassword=&#8217;welcome1&#8242;<br \/>\nconnect(adminUserName, adminPassword, adminURL)<br \/>\nsetJDBCTimeoutProperties()<br \/>\ndisconnect()<\/p>\n<p><span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>main()<\/p>\n<div><\/div>\n<p>Execute the script:<br \/>\ncd %WLS_HOME%\\common\\bin<br \/>\nwlst.sh SetJDBCTimeoutProperties.py<\/p>\n<p>Restart the server after successful execution.<\/p><\/div>\n<div><\/div>\n<div><\/div>\n<div><\/div>\n<div><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2015\/04\/weblogicssrrerew-7.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4639\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2015\/04\/weblogicssrrerew-7.jpg\" alt=\"weblogicssrrerew-7\" width=\"649\" height=\"453\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/weblogicssrrerew-7.jpg 649w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/weblogicssrrerew-7-300x209.jpg 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/weblogicssrrerew-7-150x105.jpg 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/weblogicssrrerew-7-400x279.jpg 400w\" sizes=\"(max-width: 649px) 100vw, 649px\" \/><\/a> <a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2015\/04\/weblogicssrrerew-8.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4640\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2015\/04\/weblogicssrrerew-8.jpg\" alt=\"weblogicssrrerew-8\" width=\"580\" height=\"317\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/weblogicssrrerew-8.jpg 580w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/weblogicssrrerew-8-300x164.jpg 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/weblogicssrrerew-8-150x82.jpg 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/weblogicssrrerew-8-400x219.jpg 400w\" sizes=\"(max-width: 580px) 100vw, 580px\" \/><\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>There are different timeout properties in JDBC connection, this post explain the approach to set some of the important timeout properties through WLST script.<\/p>\n<p>Inactive Connection Timeout: The number of inactive seconds on a reserved connection before WebLogic Server reclaims the connection and releases it back into the connection pool. You can use the Inactive [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4638"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4638"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4638\/revisions"}],"predecessor-version":[{"id":4641,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4638\/revisions\/4641"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}