I would like to connect to my Atlas cluster using eclipselinks nosql feature. I manage to connect to a local mongodb using this persistance.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="mongo-test" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<properties>
<property name="eclipselink.target-database" value="org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform"/>
<property name="eclipselink.nosql.connection-spec" value="org.eclipse.persistence.nosql.adapters.mongo.MongoConnectionSpec"/>
<property name="eclipselink.nosql.property.mongo.port" value="27017"/>
<property name="eclipselink.nosql.property.mongo.host" value="localhost"/>
<property name="eclipselink.nosql.property.mongo.db" value="xrn-testing"/>
<property name="eclipselink.logging.level" value="FINEST"/>
</properties>
</persistence-unit>
</persistence>
However from Atlas I just get a connection string which looks like this:
mongodb+srv://<user>:<password>@test-cluster-0.xxxx.mongodb.net/?retryWrites=true&w=majority
Question: How do I need to set up my persistence.xml to connect to the cluster. In particular:
- what’s the port? Is it still 27017? Do I need to provide it at all?
- is test-cluster-0.xxxx.mongodb.net the correct host? What about the query string?
- how to correctly include user name and password?
Or does anybody have an example persistence.xml for an Atlas cluster?
Greetings,
Marcus