From: Rafał Staniszewski <rafal-staniszewski@o2.pl>
To: JDBC-postgre-list <pgsql-jdbc@postgresql.org>
Subject: Arrays and setObject problem
Date: Fri, 02 Jul 2004 13:43:03 +0200
Message-ID: <40E54A47.1020207@o2.pl> (raw)
Hi all,
During development of my web application I found a problem I can't handle.
I have a relation:
CREATE TABLE public.test
(
id int4,
tab varchar[]
) WITHOUT OIDS;
Using jdbc and prepared statement I'm trying to put data into this table:
public add(Connection conn,int id,Vector v) {
PreparedStatement pstmt = conn.prepareStatement("insert into
test(id,tab) values(?,?)");
pstmt.setInt(1,id);
pstmt.setObject(2,v.toArray());
pstmt.executeUpdate();
pstmt.close();
}
When I run this I get:
e.getErrorCode() -> 0
e.getMessage() -> ERROR: missing dimension value
e.getSQLState() -> 22P02
I tried to change 'pstmt.setObject(2,v.toArray());' with:
String[] att = new String[v.size()];
for(int i=0;i<v.size();i++) {
att[i] = v.get(i).toString();
// and also with
// att[i] = (String)v.get(i)
}
pstmt.setObject(2,att);
but still the same error occurred.
I'm using:
postegresql: 7.4.2
jdbc driver: pg74.213.jdbc3.jar
Thanks in advance for help.
Rafal Staniszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: rafal-staniszewski@o2.pl
Subject: Re: Arrays and setObject problem
In-Reply-To: <40E54A47.1020207@o2.pl>
References: <40E54A47.1020207@o2.pl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox