Home  >  Article  >  Database  >  Java无法连接MongoDB问题

Java无法连接MongoDB问题

WBOY
WBOYOriginal
2016-06-07 17:02:581027browse

由于开发用的Linux服务器在一个相对封闭的环境中,只有通过SSH访问22端口。于是就用putty做了一个SSH forwarding,将本机的27018

背景介绍:

由于开发用的Linux服务器在一个相对封闭的环境中,只有通过SSH访问22端口。于是就用putty做了一个SSH forwarding,将本机的27018端口映射到远程的27017端口。在cmd中通过mongo localhost:27018成功连接,,并且进行了操作。

现象:

在程序中通过

  • 连接远程的服务器上的MongoDB,程序运行时出现了下面错误: 从异常信息中看出,localhost被替换成了“机器名/IP地址”的形式,而这个组合在cmd 中也是不能连接的。

    linux

  • Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn