Cannot insert String[] objects in PreparedStatements !!!

Hello guys,

I'm using PostgreSQL 7.0.3 for a website project.

I've got a table in the website database system which has a integer array type,

e.g.

create table preferences(

user_id integer references user,

music varchar(20)[5],

magazines varchar(20)[5],

channel varchar(10)[3]

)

I've also got an javabean which holds the use preferences object

publicclass userPref{

private String[] music;

private String[] magazines;

private String[] channel;

privateint userId;

// a constructor which uses reflection

public userPref(HttpServletRequest request){

...

}

}

know i would like to be able to insert some values in that

table using java.sql library.

i've got

Connection con = broker.getConnection();// the connection pool releases one connection

PreparedStatement ps = con.prepareStatement;

ps.setInt(1,user.getId());

...

But for the rest of the fields, what should I use ?

I saw that there was setArray method in the PreparedStatement that uses java.sql.Array Class

Is it the method that I've got to use. If so, do I need to implement it ?

Please help me,

touco

[1774 byte] By [touco] at [2007-9-26 1:17:30]
# 1
I have no idea if that is the method you have to use or whether it will do what you want, but you do not have to implement it. That is the responsibility of the JDBC driver writer, just like the other 100-odd methods of PreparedStatement.
DrClap at 2007-6-29 0:47:07 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Yes, you need to use setArray for these. Take a look at this thread for an example: http://forums.java.sun.com/thread.jsp?forum=48&thread=86835
swatdba at 2007-6-29 0:47:07 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...