Inserting an array into a table

From: "Jones, Ian (NASC)" <JonesTI(at)navair(dot)navy(dot)mil>
To: "'pgsql-jdbc(at)postgresql(dot)org'" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Inserting an array into a table
Date: 2002-02-22 18:39:37
Message-ID: A9DDD195B23AD311BD4B0000F809638E8D8FB3@nems15.nawcad.navy.mil
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello,

I am a little new to JDBC, and am having a little bit of trouble finding a
way to update an array field in a database. I am using the JDBC driver 7.2
which claims to have the built in array support... I believe this, because I
can get an array out of the database and I can materialize it. I cannot
however find a way to modify it and resave it to the database. I either need
to be able to do this, or to simply create an array, and somehow send it to
the database to be inserted programmatically (i.e. I need to use a prepared
statement or the like in a loop).

I have tried the likes of

myPreparedStatement.setObject(1,arrayVariable);

on some recommendations I found online, but this does not seem to work
properly. When I try to use the version of setObject that takes the object
type as a third parameter using Types.ARRAY I get an error message that
claims it did not recognize this value. I also went the route of trying to
materialize they array as a resultSet and modify it, then reinsert the Array
Object returned from the original query. This however does not work either,
as the Array Interface has no method to return an updateable resultSet (or
it least it doesn't seem to).

If anyone has an answer I would really appreciate it. If anyone has a
Correct Answer I would appreciate it even more. As usual, dumb looks are
still free. :)

Thanks,

Ian

Browse pgsql-jdbc by date

  From Date Subject
Next Message Nick Fankhauser 2002-02-22 19:31:56 Re: strange error
Previous Message Nick Fankhauser 2002-02-22 12:51:21 Re: strange error