Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using setString in PreparedStatement

Status
Not open for further replies.

sikar

Programmer
Jun 4, 2003
15
0
0
US
Hi,

I am using PreparedStatement and my query is like this:

Select all_dest, city_type from TableA
where city_type in (?) " ;

In the PreparedStatement, I am using a String to provide value for city_type

pstmt.setString(1, strCityType);

Now this strCityType has value = 'I', 'T', 'A';

On executing the query I am getting SQLException, Error Code 302.

Any kind of help to solve this problem will be highly appreciated. I am in urgent need to solve this problem.

Thanks
Sikar


 
I've never used prepared statements like this but I would expect you'd have to explicitly put a placeholder for each item, thus:-
Code:
Select all_dest, city_type from TableA
where  city_type in (?,?,?);
with setting the params like this:-
Code:
pstmt.setString(1, "I");
pstmt.setString(1, T");
pstmt.setString(1, "A");

Tim
 
... or even
Code:
pstmt.setString(1, "I");
pstmt.setString([b]2[/b], T");
pstmt.setString([b]3[/b], "A");

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top