Hi Christian.
You hit the nail right on the head.
Thank you very much.
Michael MacIntyre

Christian Krone wrote:

Hello,

Michael MacIntyre had problems with using a like predicate in a prepared
statement:

[...] where fname like ?");
This executes, returns nothing - it should

> ivPs.setString(1,someParam); Yes, because a like predicate without surrounding % is like using the = comparison, so the complete fname must be given to get some lines returned.

[...] where fname like '%?%' ");
ivPs.setString(1,someParam);
Fails

It should also fail, because a question mark inside quotes is just a string with a question mark, not a parameter placeholder.

[...] where fname like ?");
ivPs.setString(1," '%" + someParam + "%' ");
This executes, returns nothing

Almost correct :-) You should not put the quotes and/or any surrounding whitespace into the parameter, only the pure pattern. So (without any testing) I would suggest the following: [...] where fname like ?"); ivPs.setString(1,"%" + someParam + "%");

I hope that helps,
Krischan




--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to