使用Java 8连接Mongo DB 3.8.1时出错

时间:2018-09-11 00:59:45

标签: java windows mongodb database-connection

*While trying to connect mongodb using java in windows I am getting below error*

    NFO: Exception in monitor thread while connecting to server localhost:27018
    com.mongodb.MongoSocketOpenException: Exception opening socket
        at com.mongodb.internal.connection.SocketChannelStream.open(SocketChannelStream.java:60)
        at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:126)
        at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117)
        at java.lang.Thread.run(Unknown Source)
    Caused by: java.net.ConnectException: Connection refused: no further information
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
        at sun.nio.ch.SocketAdaptor.connect(Unknown Source)
        at com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:64)
        at com.mongodb.internal.connection.SocketChannelStream.open(SocketChannelStream.java:57)
        ... 3 more

注意:-我有Mongo DB 4.0.2,并使用端口27017和主机本地主机。

请帮助。

0 个答案:

没有答案