We recently had security scan done for our application and we found few blind sql injection issues . However i found that we are getting this issue even after using prepared statement .
Using prepared statement alone does not solve bind sql injection issues? Having string concatenation in prepared statement spoils all the advantage ?
private static final String selectStaement=" select email,phone from tuser where name=? ";
public void execute(String name) throws SQLException {
PreparedStatement preparedStatement = theConnection.prepareStatement(selectStaement + " ORDER by name");
preparedStatement.setString(1, name);
rs = preparedStatement.executeQuery();
}
Can anybody let me know whats wrong with this code and how to solve this ? is data validation only way ? what if i want to allow all chars ?