How to set list of parameters on prepared statement?

Chris picture Chris · Aug 20, 2009 · Viewed 98.9k times · Source

i have a list of names e.g.:

List<String> names = ...
names.add('charles');
...

and a statement:

PreparedStatement stmt = 
  conn.prepareStatement('select * from person where name in ( ? )');

how to do the following:

stmt.setParameterList(1,names);

Is there a workaround? can someone explain why this method is missing?

using: java, postgresql, jdbc3

Answer

earcam picture earcam · Nov 7, 2012

This question is very old, but nobody has suggested using setArray

This answer might help https://stackoverflow.com/a/10240302/573057