String username="abc";
String pwd="abc";
String query="Select username,pwd where username = ? and pwd = ?";
I want to replace character '?' in this string by different values with username and pwd specifed..Is there any function by which we can find '?' which is there two times and replace it with username and pwd?
Sure, have a look at
String.replaceFirstfor instance:Keep in mind though, that you probably want to properly escape
usernameandpwd.Consider for instance what happens if I provide something like
as password.
For more information on this, have a look at the various answers to:
If possible, use
PreparedStatements!