Mongodb错误,第一次安装没有经验

代码
package com.yansl;

import java.net.UnknownHostException;

import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.Mongo;
import com.mongodb.MongoException;

public class MongodbTest {

private Mongo mong=null;

private DB db=null;

private DBCollection dbc=null;

public MongodbTest()
{
try {
mong=new Mongo();
System.out.println(mong);
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MongoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
db=mong.getDB("MyTest");
System.out.println(db);

dbc=db.getCollection("table1");
System.out.println(dbc);
}

public void selectAll(){
System.out.println("查询table1中的所有数据:");

//得到查询
DBCursor cur = dbc.find();

//遍历结果
while(cur.hasNext()){
System.out.println(cur.next());
}
}

public static void main(String[] args) {
MongodbTest m=new MongodbTest();
m.selectAll();
}

}

输出和错误信息
————————————————————————————————————————————————

Mongo: 127.0.0.1:27017
MyTest
table1
查询table1中的所有数据:
2012-3-12 17:47:21 com.mongodb.DBTCPConnector fetchMaxBsonObjectSize
警告: null
java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused: connect
at com.mongodb.DBPort._open(DBPort.java:206)
at com.mongodb.DBPort.go(DBPort.java:94)
at com.mongodb.DBPort.go(DBPort.java:75)
at com.mongodb.DBPort.findOne(DBPort.java:129)
at com.mongodb.DBPort.runCommand(DBPort.java:138)
at com.mongodb.DBTCPConnector.fetchMaxBsonObjectSize(DBTCPConnector.java:409)
at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:396)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:192)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295)
at com.mongodb.DBCursor._check(DBCursor.java:354)
at com.mongodb.DBCursor._hasNext(DBCursor.java:484)
at com.mongodb.DBCursor.hasNext(DBCursor.java:509)
at com.yansl.MongodbTest.selectAll(MongodbTest.java:45)
at com.yansl.MongodbTest.main(MongodbTest.java:52)
2012-3-12 17:47:23 com.mongodb.DBTCPConnector$MyPort error
严重: MyPort.error called
java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused: connect
at com.mongodb.DBPort._open(DBPort.java:206)
at com.mongodb.DBPort.go(DBPort.java:94)
at com.mongodb.DBPort.go(DBPort.java:75)
at com.mongodb.DBPort.call(DBPort.java:65)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:201)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295)
at com.mongodb.DBCursor._check(DBCursor.java:354)
at com.mongodb.DBCursor._hasNext(DBCursor.java:484)
at com.mongodb.DBCursor.hasNext(DBCursor.java:509)
at com.yansl.MongodbTest.selectAll(MongodbTest.java:45)
at com.yansl.MongodbTest.main(MongodbTest.java:52)
2012-3-12 17:47:24 com.mongodb.DBTCPConnector fetchMaxBsonObjectSize
警告: null
java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused: connect
at com.mongodb.DBPort._open(DBPort.java:206)
at com.mongodb.DBPort.go(DBPort.java:94)
at com.mongodb.DBPort.go(DBPort.java:75)
at com.mongodb.DBPort.findOne(DBPort.java:129)
at com.mongodb.DBPort.runCommand(DBPort.java:138)
at com.mongodb.DBTCPConnector.fetchMaxBsonObjectSize(DBTCPConnector.java:409)
at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:396)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:192)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:220)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295)
at com.mongodb.DBCursor._check(DBCursor.java:354)
at com.mongodb.DBCursor._hasNext(DBCursor.java:484)
at com.mongodb.DBCursor.hasNext(DBCursor.java:509)
at com.yansl.MongodbTest.selectAll(MongodbTest.java:45)
at com.yansl.MongodbTest.main(MongodbTest.java:52)
2012-3-12 17:47:25 com.mongodb.DBTCPConnector$MyPort error
严重: MyPort.error called
java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused: connect
at com.mongodb.DBPort._open(DBPort.java:206)
at com.mongodb.DBPort.go(DBPort.java:94)
at com.mongodb.DBPort.go(DBPort.java:75)
at com.mongodb.DBPort.call(DBPort.java:65)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:201)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:220)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295)
at com.mongodb.DBCursor._check(DBCursor.java:354)
at com.mongodb.DBCursor._hasNext(DBCursor.java:484)
at com.mongodb.DBCursor.hasNext(DBCursor.java:509)
at com.yansl.MongodbTest.selectAll(MongodbTest.java:45)
at com.yansl.MongodbTest.main(MongodbTest.java:52)
2012-3-12 17:47:26 com.mongodb.DBTCPConnector fetchMaxBsonObjectSize
警告: null
java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused: connect
at com.mongodb.DBPort._open(DBPort.java:206)
at com.mongodb.DBPort.go(DBPort.java:94)
at com.mongodb.DBPort.go(DBPort.java:75)
at com.mongodb.DBPort.findOne(DBPort.java:129)
at com.mongodb.DBPort.runCommand(DBPort.java:138)
at com.mongodb.DBTCPConnector.fetchMaxBsonObjectSize(DBTCPConnector.java:409)
at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:396)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:192)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:220)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:220)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295)
at com.mongodb.DBCursor._check(DBCursor.java:354)
at com.mongodb.DBCursor._hasNext(DBCursor.java:484)
at com.mongodb.DBCursor.hasNext(DBCursor.java:509)
at com.yansl.MongodbTest.selectAll(MongodbTest.java:45)
at com.yansl.MongodbTest.main(MongodbTest.java:52)
2012-3-12 17:47:27 com.mongodb.DBTCPConnector$MyPort error
严重: MyPort.error called
java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused: connect
at com.mongodb.DBPort._open(DBPort.java:206)
at com.mongodb.DBPort.go(DBPort.java:94)
at com.mongodb.DBPort.go(DBPort.java:75)
at com.mongodb.DBPort.call(DBPort.java:65)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:201)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:220)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:220)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295)
at com.mongodb.DBCursor._check(DBCursor.java:354)
at com.mongodb.DBCursor._hasNext(DBCursor.java:484)
at com.mongodb.DBCursor.hasNext(DBCursor.java:509)
at com.yansl.MongodbTest.selectAll(MongodbTest.java:45)
at com.yansl.MongodbTest.main(MongodbTest.java:52)
Exception in thread "main" com.mongodb.MongoException$Network: can't call something
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:209)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:220)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:220)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295)
at com.mongodb.DBCursor._check(DBCursor.java:354)
at com.mongodb.DBCursor._hasNext(DBCursor.java:484)
at com.mongodb.DBCursor.hasNext(DBCursor.java:509)
at com.yansl.MongodbTest.selectAll(MongodbTest.java:45)
at com.yansl.MongodbTest.main(MongodbTest.java:52)
Caused by: java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused: connect
at com.mongodb.DBPort._open(DBPort.java:206)
at com.mongodb.DBPort.go(DBPort.java:94)
at com.mongodb.DBPort.go(DBPort.java:75)
at com.mongodb.DBPort.call(DBPort.java:65)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:201)
... 8 more

时间: 2024-12-06 02:50:23

Mongodb错误,第一次安装没有经验的相关文章

ios-xcode7 第一次安装显示导航页面,之后直接进入主页

问题描述 xcode7 第一次安装显示导航页面,之后直接进入主页 xcode7 中,新出了launchscreen.storyboard,我想做一个第一次安装显示一个导航界面,之后每次打开直接进入主界面,请问怎么搞? 解决方案 你在打开xcode左上角xcode黑体菜单下拉有preferrence,可以设置全部的,还有window菜单里有welcome to xcode也可以打开那个的,你自己不小心关的 解决方案二: 类似于欢迎页?在appdelegate里添加view到window上就行了,至

水晶报表13.x(Crystal Reports for VS2010)的安装部署经验

原文:水晶报表13.x(Crystal Reports for VS2010)的安装部署经验 这两天搞安装包真心坎坷,一个问题接一个问题,先是为了实现自定义动作现啃vbs,后面又是安装过程老是报错: 各种搜索.各种尝试,总算搞掂,积累了些经验,分享一下. 首先CR for VS2010的所有东东都在这里:http://scn.sap.com/docs/DOC-7824 简单说一说资源下载表的情况,资源表如图(敢情都出到SP10了,我用的是13.0.9.1312): 每列代表一类资源,每行代表一个

安装snort的daq时出现dnet header not found的错误,安装dnet后还是不行

问题描述 安装snort的daq时出现dnet header not found的错误,安装dnet后还是不行 RT, ERROR! dnet header not found,go get it from http://code.google.com/p/libdnet/ or use the --with-dnet-* options,if you have it installed in an unusual place 我用./configure --with-dnet='directo

编程c语言-C语言编译提示错误,安装

问题描述 C语言编译提示错误,安装 include 编译后提示错误,『no such file』 这是为什么? 解决方案 stdio_ext这个文件不存在.如果是你自己定义的,用引号代替尖括号看看 解决方案二: 用什么IDE呢,应该要将头文件目录设置好.如果是命令行执行编译,就要设置好相应的环境变量. 解决方案三: 你把完整的调试信息贴出来,还有开发环境是什么,这个信息太少了 解决方案四: include 这个头文件找不到了? 解决方案五: 头文件放的位置是在别的地方吧

Android应用第一次安装成功点击“打开”后Home键切出应用后再点击桌面图标返回导致应用重启问题的解决方法_Android

if((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0){ finish(); return; } 应用程序入口Activity的onCreate方法中加入上面的判断,完美解决应用程序多次重启问题. 应用程序入口Activity的onCreate方法中加入上面的判断,在setcontentview方法之前调用. 以上所述是小编给大家介绍的 Android应用第一次安装成功点击"打开"后Ho

PHP简单操作MongoDB的方法(安装及增删改查)_php技巧

本文实例讲述了PHP简单操作MongoDB的方法.分享给大家供大家参考,具体如下: php操作MongoDB的话首先从网上下载MongoDB的扩展包,https://github.com/mongodb/mongo-php-driver/downloads,选择对应的扩展包. 这是我下的,然后解压,VC6适合apache,VC9适合IIS,ts(thread safe)指PHP以模块形式运行的. 然后把其中的php_mongo.dll放在PHP中的ext文件夹中,然后在PHP.INI里面加入ex

c语言-为什么会出现 这样的 错误.第一次遇到. 病毒什么鬼.求大神 解答

问题描述 为什么会出现 这样的 错误.第一次遇到. 病毒什么鬼.求大神 解答 #include int main() { int Array[][10]={0}; int Array1[100]; int N,i,j,sum=0; int High; scanf("%d",&N); //************************************赋值 for(i = 0; i < N ; i++) { for(j = 0; j < 10; j++) {

Android环信第一次安装会搜集位置信息,能否去掉

问题描述 Android环信第一次安装会搜集位置信息,能否去掉?第一次安装启动后就会弹出警告,说环信在搜集网络位置信息,这样的用户体验很不好,能否去掉? 解决方案 D/ONE SDK: [2016/4/18 16:39:14:15]: no last location info to use D/ONE SDK: [2016/4/18 16:39:14:22]: Invalid UUID: RJZVja D/ONE SDK: [2016/4/18 16:39:14:28]: try send r

ubuntu 安装mongodb错误排查及php操作教程

一:安装mongodb //导入MongoDB公共GPG密钥 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 //创建清单文件/etc/apt/sources.list.d/mongodb.list echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/s