Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

Section D.2. Java - Pg. 268

268 A PPENDIX D MongoDB in PHP, Java, and C++ print "Initial document:n"; print print_r( $doc ); print "Updating pingtime...n"; $coll->update( array( "_id" => $doc["_id"] ), array( '$set' => array( 'attrs.pingtime' => 30 ) ) ); print "After update:n"; $cursor = $coll->find(); print print_r( $cursor->getNext() ); print "nNumber of site documents: " . $coll->count() . "n"; print "Removing documents...n"; $coll->remove(); ?> D.2 Java Among MongoDB drivers, the Java driver may be the one most frequently used in pro- duction. In addition to backing pure Java apps, the Java driver also forms the basis for the drivers powering JVM languages like Scala, Clojure, and JRuby. Java's lack of a dic- tionary literal makes the building of BSON documents more verbose, but the driver on the whole is still easy to use.