FileInputStream
FileInputStream

Reputation: 126

MongoDB Java wrong Driver

i got a problem with MongoDB. I installed it on my linux server with sudo apt-get install mongodb. When i now try to connect with my java driver to it, it says

Caused by: com.mongodb.MongoIncompatibleDriverException: This version of the driver is not compatible with one or more of the servers to which it is connected: ClusterDescription{type=STANDALONE, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=127.0.0.1:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[2, 4, 10]}, minWireVersion=0, maxWireVersion=0, maxDocumentSize=16777216, roundTripTimeNanos=708358}]}

My mongodb version on the server semms to be older than my driver version. My java driver version is 3.6 mongo-version shows me 2.4

How i could solve this problem ?

Upvotes: 2

Views: 947

Answers (3)

Rami DH
Rami DH

Reputation: 11

in case of you are using Docker to wrap your database, I suggest to change your ubuntu version to the 16.04LTS and then your mongod will install the 2.6.10 by default.

It's enough to run with java Driver, no need to get the 3.x.

here is Dockerfile :

FROM ubuntu:16.04

RUN apt-get update && apt-get install -yq mongodb && apt-get clean && rm -rf /var/lib/apt/lists/*

ENTRYPOINT mongod --dbpath /data/db --rest

Upvotes: 1

Giancarlo Romeo
Giancarlo Romeo

Reputation: 661

Try to remove the old version:

sudo apt-get purge --auto-remove mongodb-server

Then follow https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/ to install the newest official version.

Upvotes: 0

Mzzl
Mzzl

Reputation: 4126

The default mongodb package for Ubuntu is (as of 2018) version 2.4. This is a fairly old version, not compatible with a 3.x client or java driver.

Judging from your question, I assume you're not committed to a legacy version, so you'll probably want to use version 3.x

This requires some more work than just typing apt install. You can follow the recipe on the MongoDB website:

https://docs.mongodb.com/tutorials/install-mongodb-on-ubuntu/

Upvotes: 0

Related Questions