惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
WordPress大学
WordPress大学
Vercel News
Vercel News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
小众软件
小众软件
L
LangChain Blog
雷峰网
雷峰网
D
DataBreaches.Net
博客园 - 三生石上(FineUI控件)
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
NISL@THU
NISL@THU
Scott Helme
Scott Helme
量子位
S
Security Affairs
T
Threat Research - Cisco Blogs
博客园_首页
云风的 BLOG
云风的 BLOG
D
Docker
AWS News Blog
AWS News Blog
腾讯CDC
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
U
Unit 42
Recent Announcements
Recent Announcements
Apple Machine Learning Research
Apple Machine Learning Research
G
Google Developers Blog
T
The Exploit Database - CXSecurity.com
MongoDB | Blog
MongoDB | Blog
Stack Overflow Blog
Stack Overflow Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 热门话题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The Last Watchdog
The Last Watchdog
C
Cybersecurity and Infrastructure Security Agency CISA
IT之家
IT之家
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
F
Full Disclosure
L
Lohrmann on Cybersecurity
The Hacker News
The Hacker News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Y
Y Combinator Blog
S
Security @ Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Check Point Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
N
News and Events Feed by Topic
PCI Perspectives
PCI Perspectives
I
InfoQ

博客园 - zqzdong

word 宏(图片锐度和对比度) Maven父子结构的项目依赖使用以及打包依赖 在linux下执行不带主函数的jar Maven项目打包 eclipse调用c语言类库 scala rdd的交集 差集 并集 cdh 的 oozie时间校准 java 调用c语言类库 java jar包代码混淆 在windows下查找java服务cup过高问题 AES 加密解密 logger日志配置 hadoop安装 flume配置及其执行命令 java批量导入数据 kafka配置及其使用 kafkaConsumer(从topic 拿数据存入hdfs) 自定义flume的sink 在mongodb中存值,如果存在则修改,不存在插入
mongodb3.2链接设置
zqzdong · 2017-02-24 · via 博客园 - zqzdong
try {  
			ServerAddress serverAddress = new ServerAddress("localhost", 27017);  
			List<ServerAddress> addrs = new ArrayList<ServerAddress>();  
			addrs.add(serverAddress);  
			MongoCredential credential = MongoCredential.createScramSha1Credential("admin", "admin","admin".toCharArray());  
			List<MongoCredential> credentials = new ArrayList<MongoCredential>();  
			credentials.add(credential);  
			//通过连接认证获取MongoDB连接  
			MongoClient mongoClient = new MongoClient(addrs,credentials);  
			//连接到数据库  
			db = mongoClient.getDatabase("test");
			MongoCollection<Document> collection = db.getCollection("aa");
		} catch (Exception e) {  
			System.err.println( e.getClass().getName() + ": " + e.getMessage() );  
		}
//条件查询并去重
public static List<String> query2(MongoCollection<Document> collection,long beginDay,long endDay) {  
		//db.routedata.distinct(('lanmac'),{"time":{$gte:1464624000000,$lte:1464659580000}})
		List<String> list = new ArrayList<String>();
		Document query = new Document();
		query.put("time", new BasicDBObject("$gte",beginDay).append("$lte",endDay));
		MongoCursor<String> li = collection.distinct("lanmac",query,String.class ).iterator();
		while (li.hasNext()) {
			String n = li.next();
			list.add(n);
		}  
		return list;  
	}