MongoDB增删改查实例

本文涉及的产品
云数据库 MongoDB,独享型 2核8GB
推荐场景:
构建全方位客户视图
简介: MongoDB之Java测试代码(DAO层),mongodbdaoMongoInit.java是数据库初始化及连接类MongoUtils.java是对mongodb的各种操作方法MongoInit.

MongoDB之Java测试代码(DAO层),mongodbdao


MongoInit.java是数据库初始化及连接类

MongoUtils.java是对mongodb的各种操作方法

MongoInit.java

package com.wlwcloud.datatest;  import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.net.UnknownHostException; import java.util.Properties;  import org.apache.log4j.Logger;  import com.mongodb.DB; import com.mongodb.DBCollection; import com.mongodb.Mongo; import com.mongodb.MongoOptions; import com.mongodb.ServerAddress;  /**  * Mongo工具类:设计为单例模式,每当月份发生变化,数据库连接名称就会发生变化,这是业务规则 因MongoDB的Java驱动是线程安全的,对于一般的应用,只要一个Mongo实例即可,Mongo有个内置的连接池(池大小默认为10个)。  * 对于有大量写和读的环境中,为了确保在一个Session中使用同一个DB时,我们可以用以下方式保证一致性: DB mdb =mongo.getDB('dbname'); mdb.requestStart(); // 业务代码 mdb.requestDone();  * DB和DBCollection是绝对线程安全的  * @author undoner  */ public class MongoInit { 	/** DB监听端口号 */ 	private static int DBPort = 27017; 	/** DB连接URL */ 	private static String DBUrl = "localhost"; 	/** 连接DB库名称 */ 	private static String DBName = "wlwdb"; 	static Logger log = Logger.getRootLogger(); 	private static Mongo mongo; 	private static DBCollection coll; 	private static DB db;  	static { 		try { 			DBproperties(); 			MongoOptions options = new MongoOptions(); 			options.autoConnectRetry = true; 			options.connectionsPerHost = 1000; 			options.maxWaitTime = 5000; 			options.socketTimeout = 0; 			options.connectTimeout = 15000; 			options.threadsAllowedToBlockForConnectionMultiplier = 5000; 			// 事实上,Mongo实例代表了一个数据库连接池,即使在多线程的环境中,一个Mongo实例对我们来说已经足够了 			ServerAddress serverAddress = new ServerAddress(DBUrl, DBPort); 			mongo = new Mongo(serverAddress, options); 		} catch (UnknownHostException e) { 			log.info("get mongo instance failed"); 		} 	}  	static void DBproperties() { 		// 读取配置文件config.properties中的属性值 		String myFilePath = MongoInit.class.getResource("/").getPath() + "MongoDBConfig.properties"; 		Properties properties = new Properties(); 		FileInputStream fileInputStream = null; 		try { 			   fileInputStream = new FileInputStream(myFilePath); 			   properties.load(fileInputStream); 			   DBPort = Integer.parseInt((String) properties.getProperty("DBPort")); 			   DBUrl = (String) properties.getProperty("DBUrl"); 			   DBName = (String) properties.getProperty("DBName"); 			  } catch (Exception e) { 			   e.printStackTrace(); 			  } finally { 			   try { 			    fileInputStream.close(); 			   } catch (IOException e) { 			    // TODO Auto-generated catch block 			    e.printStackTrace(); 			   } 		}  	}  	public static DB getDB() { 		if (db == null) { 			db = mongo.getDB(DBName); 		} 		return db; 	}  	public static Mongo getMong() { 		return mongo; 	}  	public static DBCollection getColl(String collname) { 		return getDB().getCollection(collname); 	}  }

MongoUtils.java

package com.wlwcloud.datatest;  import java.net.UnknownHostException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Set; import java.util.regex.Pattern;  import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.ketayao.ketacustom.entity.main.User; import com.ketayao.utils.SecurityUtils; import com.mongodb.AggregationOutput; import com.mongodb.BasicDBList; import com.mongodb.BasicDBObject; import com.mongodb.BasicDBObjectBuilder; import com.mongodb.DB; import com.mongodb.DBCollection; import com.mongodb.DBCursor; import com.mongodb.DBObject; import com.mongodb.MapReduceCommand; import com.mongodb.MapReduceOutput; import com.mongodb.Mongo; import com.mongodb.MongoException; import com.mongodb.QueryBuilder; import com.mongodb.WriteConcern;  public class MongoUtils { 	//DBCursor cursor = coll.find(condition).addOption(Bytes.QUERYOPTION_NOTIMEOUT);//设置游标不要超时             /**       * 获取所有数据库实例       */       public void testGetDBS() {           List<String> dbnames = MongoInit.getMong().getDatabaseNames();           for (String dbname : dbnames) {               System.out.println("dbname:" + dbname);           }       }                /**       * 删除数据库       */       public void dropDatabase(String dbname) {           MongoInit.getMong().dropDatabase(dbname);       }                /**       * 查询所有表名       */       public void getAllCollections() {           Set<String> colls = MongoInit.getDB().getCollectionNames();           for (String s : colls) {               System.out.println("Collections:"+s);           }       }          /**       * 删除一个表       */       public void dropCollection(String collection) {           MongoInit.getColl(collection).drop();       }          /**       * 添加一条记录       */             public void addData(String dbCollection,String dataID,String dataTime,String dataContent,String dataStatus) {           DBCollection coll = MongoInit.getColl(dbCollection);           BasicDBObject doc = new BasicDBObject();           doc.put("id", dataID);           doc.put("time", dataTime);           doc.put("data", dataContent);           doc.put("status", dataStatus);           coll.insert(doc);           // 设定write concern,以便操作失败时得到提示           coll.setWriteConcern(WriteConcern.SAFE);           findOne(dbCollection);     }                /**       * 创建索引       */       public void createIndex(String collection) {           MongoInit.getColl(collection).createIndex(new BasicDBObject("index_id", 1));       }                /**       * 获取索引信息       */       public void getIndexInfo(String dbCollection) {           List<DBObject> list = MongoInit.getColl(dbCollection).getIndexInfo();           for (DBObject o : list) {               System.out.println(o);           }       }                /**       * 添加多条记录       */       public void addMultiData() {           for (int i = 0; i < 100; i++) {               MongoInit.getColl("wujintao").insert(                       new BasicDBObject().append("i", i));           }              List<DBObject> docs = new ArrayList<DBObject>();           for (int i = 0; i < 50; i++) {               docs.add(new BasicDBObject().append("i", i));           }           MongoInit.getColl("wujintao").insert(docs);           // 设定write concern,以便操作失败时得到提示           MongoInit.getColl("wujintao").setWriteConcern(WriteConcern.SAFE);       }                /**       * 查找第一条记录       */       public void findOne(String dbCollection) {           DBObject myDoc = MongoInit.getColl(dbCollection).findOne();           System.out.println(myDoc);       }                /**       * 获取表中所有记录条数       */       public void count(String dbCollection) {           System.out.println(MongoInit.getColl(dbCollection).getCount());           System.out.println(MongoInit.getColl(dbCollection).count());       }                /**       * 获取查询结果集的记录数       */       public void getCount(String dbCollection,String dataID) {           DBObject query = new BasicDBObject("id", dataID);           long count = MongoInit.getColl(dbCollection).count(query);           System.out.println(count);       }                /**       * 查询所有结果       */       public void getAllDocuments(String dbCollection) {           DBCursor cursor = MongoInit.getColl(dbCollection).find();           try {               while (cursor.hasNext()) {                   System.out.println(cursor.next());               }           } finally {               cursor.close();           }       }                /**       * 按照一个条件查询       */       public void queryByConditionOne() {           BasicDBObject query = new BasicDBObject();           query.put("name", "MongoDB");           DBCursor cursor = MongoInit.getColl("wujintao").find(query);              try {               while (cursor.hasNext()) {                   System.out.println(cursor.next());               }           } finally {               cursor.close();           }       }       public List<SensorData> queryById(String id) {      	User user = SecurityUtils.getLoginUser();         BasicDBObject query = new BasicDBObject();           System.out.print(id);         query.put("id", id);           String table="table_";         DBCursor cursor = MongoInit.getColl("table_"+user.getUsername()).find(query);           List<DBObject> list=cursor.toArray();         System.out.println(list.size());         System.out.println("dao.."+list.toString());         List<SensorData> sensordata=new ArrayList<SensorData>();         for(int i=1;i<list.size();i++)         {         	String sid=(String)list.get(i).get("id");         	String stime=(String)list.get(i).get("time");         	String sdata=(String)list.get(i).get("data");         	String status=(String)list.get(i).get("status");         	String sstatus;         	if(status.equals("0"))sstatus="正常";         	else if(status.equals("1")) sstatus="删除";         	else sstatus="未知状态";             SensorData a=new SensorData(sid,stime,sdata,sstatus);         //System.out.print(a.getData()+a.getId()+a.getStatus()+a.getTime());         sensordata.add(a);         }         return sensordata;        /* try {               while (cursor.hasNext()) {                   System.out.println(cursor.next());               }           } finally {               cursor.close();           } */      }             /**       * AND多条件查询,区间查询       */       public void queryMulti() {           BasicDBObject query = new BasicDBObject();           // 查询j不等于3,k大于10的结果集           query.put("j", new BasicDBObject("$ne", 3));           query.put("k", new BasicDBObject("$gt", 10));           DBCursor cursor = MongoInit.getColl("wujintao").find(query);           try {               while (cursor.hasNext()) {                   System.out.println(cursor.next());               }           } finally {               cursor.close();           }       }                /**       * 区间查询       * select * from table where i >50       */       public void queryMulti2() {           BasicDBObject query = new BasicDBObject();           query = new BasicDBObject();           query.put("i", new BasicDBObject("$gt", 50)); // e.g. find all where i >           DBCursor cursor = MongoInit.getColl("wujintao").find(query);           try {               while (cursor.hasNext()) {                   System.out.println(cursor.next());               }           } finally {               cursor.close();           }       }                /**       * 区间查询       * select * from table where 20 < i <= 30          //比较符             //"$gt": 大于             //"$gte":大于等于             //"$lt": 小于             //"$lte":小于等于             //"$in": 包含          */       public void queryMulti3() {           BasicDBObject query = new BasicDBObject();           query = new BasicDBObject();              query.put("i", new BasicDBObject("$gt", 20).append("$lte", 30));           DBCursor cursor = MongoInit.getColl("wujintao").find(query);           try {               while (cursor.hasNext()) {                   System.out.println(cursor.next());               }           } finally {               cursor.close();           }       }          /**       * 组合in和and select * from test_Table where (a=5 or b=6) and (c=5 or d = 6)       */       public void queryMulti4() {           BasicDBObject query11 = new BasicDBObject();           query11.put("a", 1);           BasicDBObject query12 = new BasicDBObject();           query12.put("b", 2);           List<BasicDBObject> orQueryList1 = new ArrayList<BasicDBObject>();           orQueryList1.add(query11);           orQueryList1.add(query12);           BasicDBObject orQuery1 = new BasicDBObject("$or", orQueryList1);              BasicDBObject query21 = new BasicDBObject();           query21.put("c", 5);           BasicDBObject query22 = new BasicDBObject();           query22.put("d", 6);           List<BasicDBObject> orQueryList2 = new ArrayList<BasicDBObject>();           orQueryList2.add(query21);           orQueryList2.add(query22);           BasicDBObject orQuery2 = new BasicDBObject("$or", orQueryList2);              List<BasicDBObject> orQueryCombinationList = new ArrayList<BasicDBObject>();           orQueryCombinationList.add(orQuery1);           orQueryCombinationList.add(orQuery2);              BasicDBObject finalQuery = new BasicDBObject("$and",                   orQueryCombinationList);           DBCursor cursor = MongoInit.getColl("wujintao").find(finalQuery);       }                /**       * IN查询       * if i need to query name in (a,b); just use { name : { $in : ['a', 'b'] } }       * select * from things where name='a' or name='b'       * @param coll       */       public void queryIn() {           BasicDBList values = new BasicDBList();           values.add("a");           values.add("b");           BasicDBObject in = new BasicDBObject("$in", values);           DBCursor cursor = MongoInit.getColl("wujintao").find(                   new BasicDBObject("name", in));           try {               while (cursor.hasNext()) {                   System.out.println(cursor.next());               }           } finally {               cursor.close();           }       }                /**       * 或查询       * select * from table where name  = '12' or title = 'p'       * @param coll       */       public void queryOr() {           QueryBuilder query = new QueryBuilder();           query.or(new BasicDBObject("name", 12), new BasicDBObject("title", "p"));           DBCursor cursor = MongoInit.getColl("wujintao").find(query.get()).addSpecial("$returnKey", "");           try {               while (cursor.hasNext()) {                   System.out.println(cursor.next());               }           } finally {               cursor.close();           }       }                    public void customQueryField() throws UnknownHostException{           Mongo mongo = new Mongo("localhost", 27017);           DB db = mongo.getDB("zhongsou_ad");           BasicDBObjectBuilder bulder = new BasicDBObjectBuilder();           bulder.add("times",1);           bulder.add("aid",1);           DBCursor cusor =  db.getCollection("ad_union_ad_c_1").find(new BasicDBObject(),bulder.get());           for (DBObject dbObject : cusor) {               System.out.println(dbObject);           }       }                    public void mapReduce() throws UnknownHostException{           Mongo mongo = new Mongo("localhost", 27017);           DB db = mongo.getDB("zhongsou_ad");           /***           *  book1 = {name : "Understanding JAVA", pages : 100}           *  book2 = {name : "Understanding JSON", pages : 200}           *  db.books.save(book1)           *  db.books.save(book2)           *  book = {name : "Understanding XML", pages : 300}           *  db.books.save(book)           *  book = {name : "Understanding Web Services", pages : 400}           *  db.books.save(book)           *  book = {name : "Understanding Axis2", pages : 150}           *  db.books.save(book)             *            var map = function() {              var category;              if ( this.pages >= 250 )                  category = 'Big Books';              else                  category = "Small Books";              emit(category, {name: this.name});          };          var reduce = function(key, values) {              var sum = 0;              values.forEach(function(doc) {                  sum += 1;              });              return {books: sum};          };                 var count  = db.books.mapReduce(map, reduce, {out: "book_results"});           */           try {                  DBCollection books = db.getCollection("books");                  BasicDBObject book = new BasicDBObject();               book.put("name", "Understanding JAVA");               book.put("pages", 100);               books.insert(book);                              book = new BasicDBObject();                 book.put("name", "Understanding JSON");               book.put("pages", 200);               books.insert(book);                              book = new BasicDBObject();               book.put("name", "Understanding XML");               book.put("pages", 300);               books.insert(book);                              book = new BasicDBObject();               book.put("name", "Understanding Web Services");               book.put("pages", 400);               books.insert(book);                            book = new BasicDBObject();               book.put("name", "Understanding Axis2");               book.put("pages", 150);               books.insert(book);                              String map = "function() { "+                          "var category; " +                           "if ( this.pages >= 250 ) "+                           "category = 'Big Books'; " +                         "else " +                         "category = 'Small Books'; "+                           "emit(category, {name: this.name});}";                              String reduce = "function(key, values) { " +                                        "var sum = 0; " +                                        "values.forEach(function(doc) { " +                                        "sum += 1; "+                                        "}); " +                                        "return {books: sum};} ";                              MapReduceCommand cmd = new MapReduceCommand(books, map, reduce,                 null, MapReduceCommand.OutputType.INLINE, null);                  MapReduceOutput out = books.mapReduce(cmd);                  for (DBObject o : out.results()) {                System.out.println(o.toString());               }              } catch (Exception e) {                e.printStackTrace();              }       }                    public void GroupByManyField() throws UnknownHostException{           //此方法没有运行成功           Mongo mongo = new Mongo("localhost", 27017);           DB db = mongo.getDB("libary");           DBCollection books = db.getCollection("books");           BasicDBObject groupKeys = new BasicDBObject();           groupKeys.put("total", new BasicDBObject("$sum","pages"));                      BasicDBObject condition = new BasicDBObject();           condition.append("pages", new BasicDBObject().put("$gt", 0));                            String reduce = "function(key, values) { " +                   "var sum = 0; " +                   "values.forEach(function(doc) { " +                   "sum += 1; "+                   "}); " +                   "return {books: sum};} ";           /**           BasicDBList basicDBList = (BasicDBList)db.getCollection("mongodb中集合编码或者编码")                     .group(DBObject key,   --分组字段,即group by的字段                  DBObject cond,        --查询中where条件                  DBObject initial,     --初始化各字段的值                  String reduce,        --每个分组都需要执行的Function                  String finial         --终结Funciton对结果进行最终的处理           */           DBObject obj = books.group(groupKeys, condition,  new BasicDBObject(), reduce);           System.out.println(obj);                      AggregationOutput ouput = books.aggregate(new BasicDBObject("$group",groupKeys));           System.out.println(ouput.getCommandResult());           System.out.println(books.find(new BasicDBObject("$group",groupKeys)));       }                       /**       * 分页查询          */       public void pageQuery() {           DBCursor cursor = MongoInit.getColl("wujintao").find().skip(0)                   .limit(10);           while (cursor.hasNext()) {               System.out.println(cursor.next());           }       }          /**       * 模糊查询       */       public void likeQuery() {           Pattern john = Pattern.compile("joh?n");           BasicDBObject query = new BasicDBObject("name", john);              // finds all people with "name" matching /joh?n/i           DBCursor cursor = MongoInit.getColl("wujintao").find(query);       }                /**       * 条件删除          */       public void delete(String dbCollection,String dataID) {           BasicDBObject query = new BasicDBObject();           query.put("id", dataID);           // 找到并且删除,并返回删除的对象           DBObject removeObj = MongoInit.getColl(dbCollection).findAndRemove(query);           System.out.println(removeObj);       }                /**       * 更新       */       public void update() {           BasicDBObject query = new BasicDBObject();           query.put("name", "liu");           DBObject stuFound = MongoInit.getColl("wujintao").findOne(query);           stuFound.put("name", stuFound.get("name") + "update_1");           MongoInit.getColl("wujintao").update(query, stuFound);       }   	     public void testGpsData() {       	try { 			//13862082455:117.13172:029.77659:131.2580     		Date d = new Date();  			SimpleDateFormat  sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS"); 			String dateNowStr = sdf.format(d);   			System.out.println(dateNowStr); 			     		DBCollection coll = MongoInit.getColl("table_admin");               BasicDBObject doc = new BasicDBObject();               doc.put("id", "12345678");               doc.put("time", dateNowStr);               doc.put("data", "117.13172:029.77659:131.2580");               doc.put("status", "0");             coll.insert(doc);               // 设定write concern,以便操作失败时得到提示               coll.setWriteConcern(WriteConcern.SAFE);    			BasicDBObject dsort = new BasicDBObject(); 			dsort.put("time", -1); 			 			BasicDBObject searchDevice = new BasicDBObject(); 			searchDevice.put("id", "12345678"); 			DBCursor cursor = coll.find(searchDevice).sort(dsort);		 			 			List<DBObject> list = cursor.toArray(); 			//ArrayList<SensorData> listSensorData=new ArrayList<SensorData>(list.size()); 			 			ObjectMapper mapper = new ObjectMapper();   			String jsonfromList = null; 			try { 				//list转json 				jsonfromList = mapper.writeValueAsString(list); 			} catch (JsonProcessingException e) { 				// TODO Auto-generated catch block 				e.printStackTrace(); 			}   	        //System.out.println(jsonfromList);   //			for(int i=0;i<list.size();i++) //			{ //				System.out.println((String) list.get(i).get("time")); 			//} 			 			//System.out.println(list.size()+","+listSensorData);//list的长度 //		    System.out.println(cursor.count());//计算结果的数量,类似于(mysql count()函数),不受limit的影响 			 //			while (cursor.hasNext()) { //				System.out.println(cursor.next()); //			} 			System.out.println("The Search Query has Executed!"); 		} catch (MongoException e) { 			e.printStackTrace(); 		}     }            public static void main(String[] args) {     	String dbname="wlwdb";     	String dbCollection="table_admin";     	String dbCollection1="15257102317";     	String dataID="12345678"; 		MongoUtils tb=new MongoUtils(); 		tb.testGetDBS();//查询所有数据库 		tb.getAllCollections();//查询所有表 //		 //		tb.findOne(dbCollection);//查找第一条记录 		tb.testGpsData(); 		tb.getAllDocuments(dbCollection);//获取制定表明的所有数据 		//tb.dropDatabase(dbname);//删除指定数据库 		//tb.delete(dbCollection,dataID);//删除制定表明和设备ID的数据 		//tb.dropCollection(dbCollection);// 删除一个表 		 		//tb.createIndex(dbCollection1);//创建索引 		//tb.getIndexInfo(dbCollection1);//获得表中所有索引 	} } 

MongoDBConfig.properties

#端口设置 DBPort=27017 #URL DBUrl=localhost #URL DBName=wlwdb 



[DAO层]java代码解释逐行解释

你用的应该是ibatis,这里是批量删除,相当于把一堆操作用一个事务来提交,提高数据库性能。
//函数功能,删除list中的所有元素在数据库中的记录。
protected void batchDelete(List<?> lst, String statement)
throws SQLException
{
getSqlMapClient().startBatch();//开始批量操作
//遍历list
for (Iterator localIterator = lst.iterator(); localIterator.hasNext(); ) 

Object obj = localIterator.next();
getSqlMapClient().delete(statement, obj);//statement表示你调用的删除方法,在xml文件中定义的。
}
getSqlMapClient().executeBatch();//结束批量操作
}

若转载请注明出处!若有疑问,请回复交流!
相关实践学习
MongoDB数据库入门
MongoDB数据库入门实验。
快速掌握 MongoDB 数据库
本课程主要讲解MongoDB数据库的基本知识,包括MongoDB数据库的安装、配置、服务的启动、数据的CRUD操作函数使用、MongoDB索引的使用(唯一索引、地理索引、过期索引、全文索引等)、MapReduce操作实现、用户管理、Java对MongoDB的操作支持(基于2.x驱动与3.x驱动的完全讲解)。 通过学习此课程,读者将具备MongoDB数据库的开发能力,并且能够使用MongoDB进行项目开发。 &nbsp; 相关的阿里云产品:云数据库 MongoDB版 云数据库MongoDB版支持ReplicaSet和Sharding两种部署架构,具备安全审计,时间点备份等多项企业能力。在互联网、物联网、游戏、金融等领域被广泛采用。 云数据库MongoDB版(ApsaraDB for MongoDB)完全兼容MongoDB协议,基于飞天分布式系统和高可靠存储引擎,提供多节点高可用架构、弹性扩容、容灾、备份回滚、性能优化等解决方案。 产品详情: https://www.aliyun.com/product/mongodb
目录
相关文章
|
6月前
|
人工智能 NoSQL atlas
4大企业实例解析:为何MongoDB Atlas成为AI服务构建的首选
本文所提及的仅是MongoDB Atlas在AI领域可实现功能的冰山一角
1756 1
|
NoSQL 数据可视化 关系型数据库
mongoDB入门教程三:数据库的创建和删除(增删改查)基本命令
mongoDB入门教程三:数据库的创建和删除(增删改查)基本命令
196 0
|
JSON NoSQL MongoDB
mongodb基本操作,增删改查,查询,索引,权限机制
mongodb基本操作,增删改查,查询,索引,权限机制
|
存储 NoSQL Java
SpringBoot 中使用 MongoDB 基于 MongoRepository增删改查(基础篇)
SpringBoot 中使用 MongoDB 基于 MongoRepository增删改查(基础篇)
590 0
|
3月前
|
人工智能 NoSQL Go
Go MongoDB Driver 实例
Go MongoDB Driver 实例
23 1
|
4月前
|
SQL NoSQL API
MongoDB 增删改查 常用sql总结
MongoDB 增删改查 常用sql总结
162 1
|
6月前
|
存储 NoSQL MongoDB
使用mongodb数据库实例
【5月更文挑战第9天】MongoDB中的集合类似关系数据库的表,但不强制模式,允许嵌入式文档以实现更灵活的数据布局。安装MongoDB在Ubuntu上涉及添加源列表和更新,CentOS则需创建配置文件。MongoDB支持备份和恢复,以及全文搜索。其灵活模式和动态模式减少了开发中的复杂性,但并非无模式,大部分数据仍具结构化特点。
153 2
|
5月前
|
NoSQL MongoDB 数据库
MongoDB的CURD(增删改查操作)
MongoDB的CURD(增删改查操作)
74 0
|
6月前
|
DataWorks NoSQL 关系型数据库
DataWorks操作报错合集之在使用 DataWorks 进行 MongoDB 同步时遇到了连通性测试失败,实例配置和 MongoDB 白名单配置均正确,且同 VPC 下 MySQL 可以成功连接并同步,但 MongoDB 却无法完成同样的操作如何解决
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
101 1