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

推荐订阅源

S
Secure Thoughts
P
Privacy International News Feed
T
Tenable Blog
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
S
Securelist
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
S
Schneier on Security
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Cyberwarzone
Cyberwarzone
月光博客
月光博客
T
The Blog of Author Tim Ferriss
Scott Helme
Scott Helme
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
C
Cisco Blogs
aimingoo的专栏
aimingoo的专栏
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LangChain Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
阮一峰的网络日志
阮一峰的网络日志
Simon Willison's Weblog
Simon Willison's Weblog
T
Tor Project blog
Security Latest
Security Latest
Blog — PlanetScale
Blog — PlanetScale
G
GRAHAM CLULEY
V
Vulnerabilities – Threatpost
博客园 - 三生石上(FineUI控件)
I
InfoQ
Spread Privacy
Spread Privacy
B
Blog RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
S
SegmentFault 最新的问题
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
MongoDB | Blog
MongoDB | Blog
C
CERT Recently Published Vulnerability Notes
A
About on SuperTechFans
博客园_首页
Engineering at Meta
Engineering at Meta
Project Zero
Project Zero
Latest news
Latest news

博客园 - 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;  
	}