How can we set username and password in spring boot neo4j programmatically

How can we set username and password in spring boot neo4j programmatically?

Assuming you are using Spring Data Neo4j 5 from the other topics, you can define your own SessionFactory or just the Configuration bean. This is usually done by the Spring Boot starter / auto configuration for you, but will not produce it if you are providing it manually.
So either:

@Configuration
public class Neo4jConfig {

	@Bean
	public SessionFactory sessionFactory() {
		org.neo4j.ogm.config.Configuration config =
		new org.neo4j.ogm.config.Configuration.Builder().credentials("neo4j", "secret").uri("neo4j://localhost:7687").build();
		return new SessionFactory(config, "com.myappliction");
	}
}

or

@Configuration
public class Neo4jConfig {

	@Bean
	public org.neo4j.ogm.config.Configuration configuration(){
		return new org.neo4j.ogm.config.Configuration.Builder().credentials("neo4j", "secret").uri("neo4j://localhost:7687").build();
	}
}

would work for you.

Can we use sdn 6 with spring boot 2.3.5?

No, this is unfortunately not possible.
Spring Data Neo4j 6 is based on the newest Spring Data commons that are based on the new version of the Spring framework itself. So the only way to not run into dependency versions issues is to upgrade to Spring Boot 2.4.