Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 52719B5DC02 for ; Mon, 19 Sep 2011 15:38:30 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 63101-02-2 for ; Mon, 19 Sep 2011 18:38:24 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail63.csoft.net (mail63.csoft.net [205.205.214.4]) by mail.postgresql.org (Postfix) with ESMTP id BAFE4B5DD19 for ; Mon, 19 Sep 2011 15:38:23 -0300 (ADT) Received: from mail63.csoft.net (localhost [127.0.0.1]) by mail63.csoft.net (Postfix) with ESMTP id 6408128424; Mon, 19 Sep 2011 14:38:23 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=csoft.net; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sel1; bh=9hxc2+KiAfT0QNUv/DB25e3LVqE=; b=soSXK8 ZLW6ZbMWjHiFR6736SIUBP6axFRkYtiOtYjIKJZyJBX5SaQDUg9wUNDz/AA08dem cBeb2/EKY/8n/d555tAqq7zKUtiNsVraSeoV46fFk0vLkGjBu01hmXpU+uBh3ywz tviTpborSn2+pLoiOXKq0eMu/rXevyy5JTaRY= Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail63.csoft.net (Postfix) with ESMTP id 3C3712840A; Mon, 19 Sep 2011 14:38:23 -0400 (EDT) Received: by leary.csoft.net (Postfix, from userid 1112) id 199FEA46F; Mon, 19 Sep 2011 14:38:22 -0400 (EDT) Date: Mon, 19 Sep 2011 14:38:22 -0400 (EDT) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Guillaume cc: pgsql-jdbc@postgresql.org Subject: Re: jdbc and automagic casting In-Reply-To: <419cf418-a33a-4c61-858c-208bf5d55844@g30g2000yqc.googlegroups.com> Message-ID: References: <419cf418-a33a-4c61-858c-208bf5d55844@g30g2000yqc.googlegroups.com> User-Agent: Alpine 2.00 (BSO 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201109/68 X-Sequence-Number: 22186 On Mon, 19 Sep 2011, Guillaume wrote: > INSERT INTO user_record (0, 'abc', '127.0.0.1') is valid and works. > The string is automagically casted as an inet value. > > Using jdbc, this is not the case, and causes me loads of trouble (and > exceptions). > Is there a way around it? If you are using setString with a parameter that's not a string, that's not correct. You should use instead setObject(x, y, Types.OTHER). > I do not have access to the java source code, there is thus no way to > update the code to programatically force a CAST. Without access to the source code you can use the connection url parameter stringtype=unspecified. http://jdbc.postgresql.org/documentation/head/connect.html#connection-parameters Kris Jurka