Java获取MongoDb的Cursor并获取数据的示例代码

   Java查询并且获取MongoDb的Cursor并获取数据的示例代码:

  

	QueryBuilder queryBuilder_zl = new QueryBuilder();
			queryBuilder_zl.put("SQDBH").is(numberLy.getMzh_zyh()).put("SJLY").is(numberLy.getSjly());
			
			if (zlevent.getBgdbh() != null & !"".equals(zlevent.getBgdbh())) {
				queryBuilder_zl.put("XH").is(zlevent.getBgdbh());
			}

			DBObject dbObjectzl = queryBuilder_zl.get();
			DBCursor dbcursor_zl = collectionzlsqjgd.find(dbObjectzl);

			while (dbcursor_zl.hasNext()) {
				Map zlsqjgdmap = (HashMap) dbcursor_zl.next();
				ZsjkZl zsjkzl = new ZsjkZl();
				zsjkzl.setYydm(yydm);
				zsjkzl.setSfzh(sfzhm);
				zsjkzl.setYydm(yydm);

				zsjkzl.setJzjlbs(numberLy.getMzh_zyh());
				zsjkzl.setZlglbs(bgdbh);
				zsjkzl.setJzjlbs(zlsqjgdmap.get("DYBH") == null ? ""
						: zlsqjgdmap.get("DYBH").toString());
				zsjkzl.setZldmxxh(zlsqjgdmap.get("XH") == null ? ""
						: zlsqjgdmap.get("XH").toString());
				zsjkzl.setZldmxxmmc(zlsqjgdmap.get("ZLXMMC") == null ? ""
						: zlsqjgdmap.get("ZLXMMC").toString());
				zsjkzl.setZlglbs(zlsqjgdmap.get("SQDBH") == null ? ""
						: zlsqjgdmap.get("SQDBH").toString());
				zsjkzl_list.add(zsjkzl);
			}
		}

 

你可能感兴趣的:(Java获取MongoDb的Cursor并获取数据的示例代码)