{"id":4860,"date":"2017-07-14T11:54:06","date_gmt":"2017-07-14T02:54:06","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=4860"},"modified":"2020-05-28T14:23:58","modified_gmt":"2020-05-28T05:23:58","slug":"connection-%ec%9c%a0%ec%a7%80%eb%a5%bc-%ec%9c%84%ed%95%9c-%eb%b0%a9%ec%95%88","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=4860","title":{"rendered":"DB Connection \uc720\uc9c0\ub97c \uc704\ud55c \ubc29\uc548"},"content":{"rendered":"<p>Java\uc5d0\uc11c DB\uc5d0 \ub300\ud55c \uc5f0\uacb0\uc744 \ubbf8\ub9ac \ub9fa\uc5b4\ub450\uace0 \uc0ac\uc6a9\ud558\ub294 Connection Pool\uc744 \ud65c\uc6a9\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. \uadf8\ub7f0\ub370 \ubb38\uc81c\ub294 Connection\uc774 \uc77c\uc815 \uc2dc\uac04 \uc544\ubb34\ub7f0 \uc0ac\uc6a9\uc774 \uc5c6\uc744 \uacbd\uc6b0 \uc11c\ubc84 \ub2e8\uc5d0\uc11c \ud574\ub2f9 Connection\uc758 \uc5f0\uacb0\uc744 \ub04a\ub294 \uacbd\uc6b0\uc778\ub370\uc694. \uc774\ub294 \uc11c\ubc84 \ub2e8\uc758 DB \uc124\uc815\uac12\uc744 \ubcc0\uacbd\ud574\uc11c \ud574\uacb0\ud560 \uc218 \uc788\uc9c0\ub9cc, \uc5ec\ub7ec\uac00\uc9c0 \uc815\ucc45 \uc0c1 DB \uc124\uc815\uac12\uc744 \ubcc0\uacbd\ud560 \uc218 \uc5c6\uc744 \ub54c\uac00 \uc788\uc2b5\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4, DB \uad00\ub9ac\uc790\uac00 \uc804\uc5d0 \uc0ac\uadc0\ub2e4\uac00 \uc774\ubcc4\ud55c \uc5ec\uc790\uce5c\uad6c\ub77c\ub358\uc9c0&#8230;&#8230;..<\/p>\n<p>\uc774\ub7ec\ud55c \uacbd\uc6b0!! \uc5d0 Connection Pool\uc744 \uc6b4\uc601\ud558\ub294 \uc5b4\ud50c\ub9ac\ucf00\uc774\uc158 \ub2e8\uc5d0\uc11c \ud574\ub2f9 Connection\uc5d0 \ub300\ud574 \uc77c\uc815 \uc2dc\uac04 \uac04\uaca9\uc73c\ub85c \uc5b4\ub5a4 \uc5f0\uc0b0\uc744 \uc8fc\uae30\uc801\uc73c\ub85c \ud638\ucd9c\ud568\uc73c\ub85c\uc368 \uc5f0\uacb0\uc744 \uacc4\uc18d \uc720\uc9c0\ud558\ub3c4\ub85d \ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc774\ub7ec\ud55c \uc5f0\uacb0 \uc720\uc9c0\ub294 \uc2a4\ub808\ub4dc\ub97c \ud1b5\ud574 \uad6c\ub3d9\ub418\ub294 \uac83\uc774 \uc801\ub2f9\ud55c\ub370\uc694. \uc544\ub798\uc758 \ucf54\ub4dc\ub294 \uc774\ub7ec\ud55c \ubaa9\uc801\uc73c\ub85c \uc774\ubc88\uc5d0 \ub3c4\uc785\ud55c \uc2a4\ub808\ub4dc \ucf54\ub4dc\uc785\ub2c8\ub2e4.<\/p>\n<p>\ucf54\ub4dc\ub294 \ub9e4\uc6b0 \ub2e8\uc21c\ud558\uc9c0\ub9cc \ud5a5\ud6c4 \uae09\ud560\ub54c \uae30\uc5b5\uc744 \uc27d\uac8c \ub354\ub4ec\uc744 \uc218 \uc788\ub3c4\ub85d \uc800\uc7a5\ud574 \ub461\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">\r\npackage control;\r\n\r\nimport java.sql.Connection;\r\nimport java.sql.ResultSet;\r\nimport java.sql.Statement;\r\n\r\nimport model.DBConnection;\r\n\r\npublic class DBConnectionMaintainerThread extends Thread {\r\n    private volatile boolean bGoOn = true;\r\n\t\r\n    public void run() {\r\n        DBConnection conn = null;\r\n        Connection rConn = null;\r\n        ResultSet RS = null;\r\n        Statement readStmt = null;\r\n\t\t\r\n        while(bGoOn) {\r\n            try {\r\n                Thread.sleep(10000);\r\n\t        \t          \r\n                conn = MainEntry.dbMan.getResource(\"cim\");           \r\n                rConn = conn.getRawConnection();\r\n                readStmt =  rConn.createStatement();\r\n    \t        RS = readStmt.executeQuery(\"select 1\");   \r\n            } catch (Exception e) {\r\n                e.printStackTrace();\r\n            } finally {\r\n                if(RS != null) {\r\n                    try {\r\n                        RS.close();\r\n                        if(readStmt != null) readStmt.close();\r\n                        if(conn != null) MainEntry.dbMan.putResource(\"cim\", conn);\r\n                    } catch (Exception e) {\r\n                        e.printStackTrace();\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\ub294 10\ucd08 \uac04\uaca9\uc73c\ub85c Connection Pool\uc5d0\uc11c Connection\uc744 \uaebc\ub0b4\uc640 \uac00\uc7a5 \uac04\ub2e8\ud55c \ucffc\ub9ac\uc778 SELECT 1;\uc744 \uc8fc\uae30\uc801\uc73c\ub85c \ud638\ucd9c\ud574 \uc8fc\uace0 \uc788\uc2b5\ub2c8\ub2e4. \ucc38\uace0\ub85c Connection Pool\uc758 \ucf54\ub4dc\uc640 \uc11e\uc5ec \uc788\uc73c\ub2c8 \ud544\uc694\ud55c \ucf54\ub4dc\ub9cc \uc3d9\uc3d9 \uace8\ub77c \ubcf4\uc2dc\uae30 \ubc14\ub78d\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java\uc5d0\uc11c DB\uc5d0 \ub300\ud55c \uc5f0\uacb0\uc744 \ubbf8\ub9ac \ub9fa\uc5b4\ub450\uace0 \uc0ac\uc6a9\ud558\ub294 Connection Pool\uc744 \ud65c\uc6a9\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. \uadf8\ub7f0\ub370 \ubb38\uc81c\ub294 Connection\uc774 \uc77c\uc815 \uc2dc\uac04 \uc544\ubb34\ub7f0 \uc0ac\uc6a9\uc774 \uc5c6\uc744 \uacbd\uc6b0 \uc11c\ubc84 \ub2e8\uc5d0\uc11c \ud574\ub2f9 Connection\uc758 \uc5f0\uacb0\uc744 \ub04a\ub294 \uacbd\uc6b0\uc778\ub370\uc694. \uc774\ub294 \uc11c\ubc84 \ub2e8\uc758 DB \uc124\uc815\uac12\uc744 \ubcc0\uacbd\ud574\uc11c \ud574\uacb0\ud560 \uc218 \uc788\uc9c0\ub9cc, \uc5ec\ub7ec\uac00\uc9c0 \uc815\ucc45 \uc0c1 DB \uc124\uc815\uac12\uc744 \ubcc0\uacbd\ud560 \uc218 \uc5c6\uc744 \ub54c\uac00 \uc788\uc2b5\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4, DB \uad00\ub9ac\uc790\uac00 \uc804\uc5d0 \uc0ac\uadc0\ub2e4\uac00 \uc774\ubcc4\ud55c \uc5ec\uc790\uce5c\uad6c\ub77c\ub358\uc9c0&#8230;&#8230;.. \uc774\ub7ec\ud55c &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=4860\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;DB Connection \uc720\uc9c0\ub97c \uc704\ud55c \ubc29\uc548&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4860","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/4860","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4860"}],"version-history":[{"count":7,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/4860\/revisions"}],"predecessor-version":[{"id":9663,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/4860\/revisions\/9663"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4860"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}