Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 21AE2EDF36D for ; Tue, 22 May 2012 10:37:42 -0300 (ADT) Received: from auth-smtp.nebula.fi ([217.30.180.105]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SWpHM-0005Gy-Vt for pgsql-jdbc@postgresql.org; Tue, 22 May 2012 13:37:42 +0000 Received: from quadvadis.localdomain (gw.nitor.fi [83.145.228.24]) (authenticated bits=0) by auth-smtp.nebula.fi (8.13.8/8.13.4) with ESMTP id q4MDbMI8008619 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 22 May 2012 16:37:22 +0300 Message-ID: <4FBB9691.50008@nitorcreations.com> Date: Tue, 22 May 2012 16:37:21 +0300 From: Mikko Tiihonen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Simple connection failover support Content-Type: multipart/mixed; boundary="------------060103070607080608060909" X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201205/71 X-Sequence-Number: 22971 This is a multi-part message in MIME format. --------------060103070607080608060909 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, Here are two patches that add simple failover support to the jdbc driver. Patch 1 converts all references to pair of host+port variables to single InetSocketAddress Patch 2 rewrites the url parsing to support multiple host:port pairs and modifies the low level connection opening to retry once all listed addresses I also added more cases to the unit tests to verify that I did not break any functionality. * The connection url and connection parameters stay backwards compatible * If there are commas in the hostname part of the url the new code will use them to split the addresses and keep them in the defined priority order * If there is any IOException or login failure during the connection phase the code will try another listed address * I tried to keep the code still Java 1.4 compatible -Mikko --------------060103070607080608060909 Content-Type: text/x-patch; name="0001-Change-String-host-int-port-to-InetSocketAddress-add.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Change-String-host-int-port-to-InetSocketAddress-add.pa"; filename*1="tch" --------------060103070607080608060909--