Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 50A22B5DC35 for ; Mon, 19 Sep 2011 13:00:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 06628-07 for ; Mon, 19 Sep 2011 16:00:02 +0000 (UTC) Received: from news.hub.org (news.hub.org [200.46.204.72]) by mail.postgresql.org (Postfix) with ESMTP id BA964B5DC15 for ; Mon, 19 Sep 2011 13:00:01 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.4/8.14.4) with ESMTP id p8JG00Ih020615 for ; Mon, 19 Sep 2011 13:00:01 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.4/8.14.4/Submit) id p8JFkMkB095561 for pgsql-jdbc@postgresql.org; Mon, 19 Sep 2011 12:46:22 -0300 (ADT) (envelope-from news) From: boris X-Newsgroups: pgsql.interfaces.jdbc Subject: Re: jdbc and automagic casting Date: Mon, 19 Sep 2011 11:47:37 -0400 Organization: Aioe.org NNTP Server Lines: 36 Message-ID: References: <419cf418-a33a-4c61-858c-208bf5d55844@g30g2000yqc.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20110818 Icedove/3.0.11 X-Notice: Filtered by postfilter v. 0.8.2 To: pgsql-jdbc@postgresql.org 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/64 X-Sequence-Number: 22182 On 09/19/2011 10:39 AM, Guillaume wrote: > Hello, > > I have an INSERT which does not behave the same under jdbc and psql. > > With psql, INSERTing a poperly formed VARCHAR into an inet column > would work, eg.: > > =# \d user_record; > Table "user_record" > Column | Type | Modifiers > ----------------------+------------------------+----------- > id | integer | > username | character varying(64) | > registered_ip | inet | > > 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? > > I do not have access to the java source code, there is thus no way to > update the code to programatically force a CAST. do you know if they used preparedstatement or build dynamic sql? for now , I'm not sure if it would make a difference in this case.. > > Thanks for any help, > Guillaume > >