Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TIrMi-0001N5-UX for pgsql-jdbc@postgresql.org; Tue, 02 Oct 2012 01:33:40 +0000 Received: from mail-pa0-f46.google.com ([209.85.220.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TIrMe-0000Q4-Ax for pgsql-jdbc@postgresql.org; Tue, 02 Oct 2012 01:33:39 +0000 Received: by padhz1 with SMTP id hz1so4777334pad.19 for ; Mon, 01 Oct 2012 18:33:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=S51avsUwSyKEQOQa6wWqoNmAV4uKArYV93PKyUV3Wq0=; b=A2wRx32RM+2SvvxhvAF0Yh6yJWtedZp/S3CXx2BxqPBFMN74RlLT/BZbTaJWLnD9k7 Vk8sxp/4ow4XU7nMoZrORzhBW3VSEgVFMacsyc/z88jtZgFeunA6K0OmuvZmfwzBuPfB DnXW+C9P803LeSt4VvFIazqOTxEHTmWrhvVPqa0Ytufo93sg8wKMHNHEd6poH3Pd1lx5 6borgNrGlzq2rHyidRmXOgXHG9nbwLa5uvZ4YSq4iiU3Jw8xIIGyemiOp3PKsEhhmhhj 60On1VioNKzktjERBhE8Nv/jWP3qYEOD5A9bXukkg8B4ki5o5i94TU/Ruzvu1hSO+4zy x9Rw== Received: by 10.68.125.133 with SMTP id mq5mr209265pbb.138.1349141612824; Mon, 01 Oct 2012 18:33:32 -0700 (PDT) Received: from ayaki.localdomain ([114.75.212.104]) by mx.google.com with ESMTPS id te6sm45678pbc.29.2012.10.01.18.33.29 (version=SSLv3 cipher=OTHER); Mon, 01 Oct 2012 18:33:31 -0700 (PDT) Message-ID: <506A4464.6090602@ringerc.id.au> Date: Tue, 02 Oct 2012 09:33:24 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: pprotim CC: pgsql-jdbc@postgresql.org Subject: Re: Re: Not able to insert array of integers into column of type integer array References: <1348674063961-5725537.post@n5.nabble.com> <506328AC.2070206@tu-braunschweig.de> <1349107725.96229.YahooMailNeo@web120301.mail.ne1.yahoo.com> In-Reply-To: <1349107725.96229.YahooMailNeo@web120301.mail.ne1.yahoo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQlk7WtStaZowsIrZYMVZ7Ag2B2rRKwAq0pjR4UQ8kKRRKRynbHQvKPSriNjQDM3D7tl1jsR X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201210/4 X-Sequence-Number: 23328 pprotim: It looks like you tried to reply here, but just posted the quoted original message. I've been looking at the JDBC standard to see if PgJDBC can legally accept arrays of primitive types and strings, not just java.sql.Array . While this is something that the standard does not require it seems to be something people expect the driver to do, and something other drivers do. If you work with and have tested with other drivers it'd be helpful to know how they behave for as many different drivers as you have access to. -- Craig Ringer On 10/02/2012 12:08 AM, pprotim wrote: > > ------------------------------------------------------------------------ > *From:* Stefan Reiser [via PostgreSQL] <[hidden email]> > *To:* pprotim <[hidden email]> > *Sent:* Wednesday, September 26, 2012 9:40 PM > *Subject:* Re: Not able to insert array of integers into column of type > integer array > > When setting or updating arrays in a ResultSet or PreparedStatement you > can't use java array types (Integer[], ...) -- they need to be wrapped > in a "java.sql.Array". This is done using the Connection-object. > > here's an example with Floats: > > Connection con = // your connection > Double[] dbArr = // ... some java array > Array sqlArray = con.createArrayOf("float8", dbArr); > > Now "sqlArray" can be used with setArray() (or even setObject() ). > (not sure where, but there were some other examples in the JDK-docs or > pg-JDBC-docs ...)