mongoDB4.0 用事务insert 报错,求指教!
十一月 14, 2018 4:05:21 下午 com.mongodb.diagnostics.logging.JULLogger log
信息: Cluster created with settings {hosts=[192.168.0.150:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
十一月 14, 2018 4:05:21 下午 com.mongodb.diagnostics.logging.JULLogger log
信息: Cluster description not yet available. Waiting for 30000 ms before timing out
十一月 14, 2018 4:05:21 下午 com.mongodb.diagnostics.logging.JULLogger log
信息: Opened connection [connectionId{localValue:1, serverValue:20}] to 192.168.0.150:27017
十一月 14, 2018 4:05:21 下午 com.mongodb.diagnostics.logging.JULLogger log
信息: Monitor thread successfully connected to server with description ServerDescription{address=192.168.0.150:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 0, 3]}, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=2683466}
Exception in thread "main" com.mongodb.MongoClientException: Sessions are not supported by the MongoDB cluster to which this client is connected
at com.mongodb.MongoClient.startSession(MongoClient.java:579)
at com.mongodb.MongoClient.startSession(MongoClient.java:564)
at com.hyzk.mongo.dao.MongoDBUtil.install(MongoDBUtil.java:29)
at com.hyzk.mongo.controller.MongoDBController.main(MongoDBController.java:35)
===================================================================================
public void install(List<BasicDBObject> list){
MongoClient mongo = new MongoClient("192.168.0.150", 27017);
// if database doesn't exists, MongoDB will create it for you
DB db = mongo.getDB("test");
//据说是数据库不存在就创建该数据库
MongoDatabase mongoDatabase = mongo.getDatabase("user");
DBCollection table = db.getCollection("user");
ClientSession clientSession = mongo.startSession();
clientSession.startTransaction();
clientSession.commitTransaction();
table.insert(list);
clientSession.abortTransaction();
}
以上是我的代码
===================================================================================
请大牛们指导一下我