Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

A question using the setString to pass parameter

843854May 1 2004 — edited May 2 2004
Hello, 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 30 2004
Added on May 1 2004
2 comments
161 views