Arrays and setObject problem
Arrays and setObject problem
От:
Rafał Staniszewski <rafal-staniszewski@o2.pl>
Дата:
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