A question using the setString to pass parameter
843854May 1 2004 — edited May 2 2004Hello, there:
part of my SQL statement is like this:
...
p_table.user_id in (?)
...
In my JDBC code, I wrote
String str = "usr1";
ps.setString(1, str)
to pass the parameter to the SQL statement - it works fine;
However, if I wrote (in order to select from multi-users)
String str=" 'usr1', 'usr2', 'usr3' ";
ps.setString(1, str);
the code will throw a SQLException; I heard the SQL statement will automatically add single quotes on both side so I changed to:
str = " usr1', 'usr2', 'usr3 ";
but it didn't work either, the same SQL Exception is thrown.
Do any people experience this and guide me what to do?
Thanks a lot,
Sway