Not able to connect mongodb atlas with java

following is the code.

public static void main(String[] args) {
	
	ConnectionString connectionString = new ConnectionString("mongodb+srv://demo:demo123@cluster0.f02.mongodb.net/test?retryWrites=true&w=majority");
	MongoClientSettings settings = MongoClientSettings.builder()
	        .applyConnectionString(connectionString)
	        .build();
	MongoClient mongoClient = MongoClients.create(settings);
	MongoDatabase database = mongoClient.getDatabase("test");
	
	System.out.println(database.getName());
}

while running this it gives below error

Exception in thread "main" com.mongodb.MUQrUTqDch7niLusZ4SxSTAcoawWJK91eT: Unable to look up TXT record for host cluster0.f02ax.mongodb.net
	at com.mongodb.internal.dns.DefaultDnsResolver.resolveAdditionalQueryParametersFromTxtRecords(DefaultDnsResolver.java:131)
	at com.mongodb.ConnectionString.<init>(ConnectionString.java:381)
	at com.example.demo.em.main(em.java:13)
Caused by: javax.naming.CommunicationException: DNS error [Root exception is java.net.SocketTimeoutException: Receive timed out]; remaining name 'cluster0.f02ax.mongodb.net'
	at jdk.naming.dns/com.sun.jndi.dns.DnsClient.query(DnsClient.java:316)
	at jdk.naming.dns/com.sun.jndi.dns.Resolver.query(Resolver.java:81)
	at jdk.naming.dns/com.sun.jndi.dns.DnsContext.c_getAttributes(DnsContext.java:434)
	at java.naming/com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:235)
	at java.naming/com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:141)
	at java.naming/com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:129)
	at java.naming/javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:171)
	at com.mongodb.internal.dns.DefaultDnsResolver.resolveAdditionalQueryParametersFromTxtRecords(DefaultDnsResolver.java:114)
	... 2 more
Caused by: java.net.SocketTimeoutException: Receive timed out
	at java.base/sun.nio.ch.DatagramChannelImpl.trustedBlockingReceive(DatagramChannelImpl.java:700)
	at java.base/sun.nio.ch.DatagramChannelImpl.blockingReceive(DatagramChannelImpl.java:630)
	at java.base/sun.nio.ch.DatagramSocketAdaptor.receive(DatagramSocketAdaptor.java:239)
	at java.base/java.net.DatagramSocket.receive(DatagramSocket.java:569)
	at jdk.naming.dns/com.sun.jndi.dns.DnsClient.doUdpQuery(DnsClient.java:426)
	at jdk.naming.dns/com.sun.jndi.dns.DnsClient.query(DnsClient.java:214)
	... 9 more

The TXT DNS entry is fine. Try switching DNS provider by using 8.8.8.8.

How to change dns provider…can you elaborate?