Can you post clearly, what sort of error you are getting.
And the portion of the code where you are getting error.
I can't asure you that i can solve your's.But I can try,bcoz i have worked with the similar kind of problem long back.
You don't necessarily need to solve it. The SQL compilation overhead is not that significant in many cases. However, if you insist on using PreparedStatement you could do this:
If you know (or can limit) how many values can go into your IN () clause you could use as many parameter markers as you need (replacing some markers with the same values if there are less values than the maximum).
Say, you expect the maximum of 5 ID values to be provided. You the would create a statement like this:
SELECT ... WHERE ID IN (?, ?, ?, ?, ?) ...
If all 5 values are provided for a certain invokation of the query you would call setInt() for each of them.
If only 1 value is provided you still call setInt 5 times but use the same value every time.