在Informix 12.10.FC5版本中,支持Mongo的nosql,需要启动监听如下:java -cp $INFORMIXDIR/bin/jsonListener.jar com.ibm.nosql.informix.server.ListenerCLI -config $INFORMIXDIR/etc/jsonListener.properties -start
用java操作:
MongoClient mongoClient = new MongoClient("localhost",27017);
MongoDatabase db = mongoClient.getDatabase("stores_demo");
MongoCollection collection = db.getCollection("customer");
System.out.println(collection.find());//可以正常打印
System.out.println("=========================================");
System.out.println(collection.find().iterator());//出错
错误信息如下:
Jul 4, 2016 2:36:56 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
com.mongodb.FindIterableImpl@5c1428ea
=========================================
Jul 4, 2016 2:36:57 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, all=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing out
Jul 4, 2016 2:36:57 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Exception in monitor thread while connecting to server localhost:27017
com.mongodb.MongoException: org.bson.BsonInvalidOperationException: Value expected to be of type INT32 is of unexpected type STRING
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:125)
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128)
at java.lang.Thread.run(Thread.java:679)
Caused by: org.bson.BsonInvalidOperationException: Value expected to be of type INT32 is of unexpected type STRING
at org.bson.BsonValue.throwIfInvalidType(BsonValue.java:397)
at org.bson.BsonValue.asInt32(BsonValue.java:94)
at com.mongodb.connection.DescriptionHelper.getVersion(DescriptionHelper.java:121)
at com.mongodb.connection.DescriptionHelper.createConnectionDescription(DescriptionHelper.java:58)
at com.mongodb.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:85)
at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:43)
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115)
... 2 more