Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id E0A95634706 for ; Wed, 17 Jun 2009 17:10:46 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 45684-09 for ; Wed, 17 Jun 2009 17:10:39 -0300 (ADT) X-Greylist: delayed 00:06:02.65573 by SQLgrey-1.7.6 Received: from mail-qy0-f195.google.com (mail-qy0-f195.google.com [209.85.221.195]) by mail.postgresql.org (Postfix) with ESMTP id 79D406333BA for ; Wed, 17 Jun 2009 17:10:43 -0300 (ADT) Received: by qyk33 with SMTP id 33so725628qyk.15 for ; Wed, 17 Jun 2009 13:10:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=tRC2FjNYYqMSWhCZYHPsNDteEQ7nkoWBA57KNvy8spA=; b=RvTuao5idALM1xPPi4gAmVcRIB0EMmaq8IUOFYc7KnzHxqKbRQbhTwyVs3pWHwejbu LE+0WLSos3lQO2Tl++RH2r6/DA6B7g7n5SZv8V4UkmfOfceuW2vnCCWPI4hiIryxKkJo YcNCXHe/5I22HjiXlVRn3ELgIrSidPAJV48I0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=gnM0XK6Onbka7fIHVisrwG9ZjFCGv0500qaf93egBjCtFh6UDyAYj8nbYS5hwvpum3 GnMsLZgpOGVGkk8R3BI0SSetPRCxZEGhgbxKHC2vpt+LEiFvZ0zu/VdKo0CyPvG+jlFX MJK2wyuCzCE3TeLMwswebn59ENPAMjs0FaZO4= MIME-Version: 1.0 Received: by 10.220.77.68 with SMTP id f4mr839344vck.44.1245269062080; Wed, 17 Jun 2009 13:04:22 -0700 (PDT) In-Reply-To: References: From: Dennis Brakhane Date: Wed, 17 Jun 2009 22:04:01 +0200 Message-ID: <226a19190906171304n2b306a0ufc676ad7be76b0e1@mail.gmail.com> Subject: Re: Please help! - Constraints Exception To: Ivan Bojer Cc: pgsql-jdbc@postgresql.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200906/69 X-Sequence-Number: 19733 On Wed, Jun 17, 2009 at 9:57 PM, Ivan Bojer wrote: > I have a table with UNIQUE constraint on the column. Inserting 2 of > same values on it fails (as it should) > and I can see DBLog Error message. Alas, there is no exception thrown > from JDBC so that I can properly > handle it. This is from memory, so if I talk nonsense, I hope somebody corrects me. The exception thrown should be a SQLException. These have a "getSQLState" method which returns a string. If this string is "23505", you have a UNIQUE violation. You can see the possible error codes here: http://www.postgresql.org/docs/8.3/static/errcodes-appendix.html