{"id":535,"date":"2009-09-30T15:33:24","date_gmt":"2009-09-30T20:33:24","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=535"},"modified":"2011-10-21T08:52:29","modified_gmt":"2011-10-21T13:52:29","slug":"jdbc-connection-timeout","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2009\/09\/30\/jdbc-connection-timeout\/","title":{"rendered":"JDBC connection timeout"},"content":{"rendered":"<p>While testing a remote data center today, we had some network connectivity issues.  We twiddled our thumbs while waiting for connections to throw an exception due to a network block.  <\/p>\n<p>I found the setLoginTimeout() method on the DriverManager class.  You can use it as show below:<\/p>\n<pre lang=\"java\" line=\"1\">\r\nimport java.sql.*;\r\n\r\npublic class checkConn {\r\n  public static void main(String[] args) {\r\n    try {\r\n      Class.forName(\"oracle.jdbc.driver.OracleDriver\");\r\n      System.out.println(DriverManager.getLoginTimeout());\r\n      DriverManager.setLoginTimeout(20);\r\n      System.out.println(DriverManager.getLoginTimeout());\r\n      Connection conn = DriverManager.getConnection(\"jdbc:oracle:thin:@oh2xpwcdg01:2484\/hidden.service.domain\",\r\n                                                    args[0],\r\n                                                    args[1]);\r\n      ResultSet rst = conn.createStatement().executeQuery(\"select sysdate, to_char ( sysdate, 'DD-MON-YYYY') from dual\");\r\n      if (rst.next()) {\r\n        System.out.println(rst.getDate(1) + \" \" + rst.getString(1));\r\n      }\r\n    }\r\n    catch(Exception e) {\r\n      e.printStackTrace();\r\n    }\r\n  }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>While testing a remote data center today, we had some network connectivity issues. We twiddled our thumbs while waiting for connections to throw an exception due to a network block. I found the setLoginTimeout() method on the DriverManager class. You&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2009\/09\/30\/jdbc-connection-timeout\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[19,24,25,22],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/535"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=535"}],"version-history":[{"count":9,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/535\/revisions"}],"predecessor-version":[{"id":1656,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/535\/revisions\/1656"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=535"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}