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!

wild card on mysql prepared statement

843859Dec 6 2005 — edited Dec 7 2005
hi i want to use wild card % sign to MySQL prepared statement. example
pstmt=con.prepareStatement("select SALARY from SALARIES where NAME like ?");
pstmt.setString(1,name);
ResultSet rs=pstmt.executeQuery();

what if the value of name variable is ch and i want to search all names that with the characters "ch" regardles of what comes before and after. for not prepared statement.
stmt.executeQuery("select salary from salaries where name=%ch%");

thanks in advance for your help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 4 2006
Added on Dec 6 2005
4 comments
358 views