summaryrefslogtreecommitdiff
path: root/src/mongo/client/examples/second.cpp
diff options
context:
space:
mode:
authorApollon Oikonomopoulos <apoikos@debian.org>2016-01-14 00:10:06 +0200
committerApollon Oikonomopoulos <apollon@skroutz.gr>2016-01-14 00:10:06 +0200
commit374e1947abcd3e127a2a613aff73ecffdb9199ea (patch)
treed83973c3c9802450acd5b5e86fe0d4e8e60a3a1b /src/mongo/client/examples/second.cpp
parent65585c90b12d6523bea75a2aebaae2a2fdf9e641 (diff)
Imported Upstream version 2.6.11upstream/2.6.11
Diffstat (limited to 'src/mongo/client/examples/second.cpp')
-rw-r--r--src/mongo/client/examples/second.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/mongo/client/examples/second.cpp b/src/mongo/client/examples/second.cpp
index e4503957afd..87b34a482e7 100644
--- a/src/mongo/client/examples/second.cpp
+++ b/src/mongo/client/examples/second.cpp
@@ -33,9 +33,13 @@ int main( int argc, const char **argv ) {
port = argv[ 2 ];
}
- scoped_ptr<ScopedDbConnection> connPtr( ScopedDbConnection::getScopedDbConnection(
- string( "127.0.0.1:" ) + port ) );
- ScopedDbConnection& conn = *connPtr;
+ Status status = client::initialize();
+ if ( !status.isOK() ) {
+ std::cout << "failed to initialize the client driver: " << status.toString() << endl;
+ return EXIT_FAILURE;
+ }
+
+ ScopedDbConnection conn(string( "127.0.0.1:" ) + port);
const char * ns = "test.second";
@@ -45,6 +49,12 @@ int main( int argc, const char **argv ) {
conn->insert( ns , BSON( "name" << "sara" << "num" << 24 ) );
std::auto_ptr<DBClientCursor> cursor = conn->query( ns , BSONObj() );
+
+ if (!cursor.get()) {
+ cout << "query failure" << endl;
+ return EXIT_FAILURE;
+ }
+
cout << "using cursor" << endl;
while ( cursor->more() ) {
BSONObj obj = cursor->next();
@@ -54,4 +64,6 @@ int main( int argc, const char **argv ) {
conn->ensureIndex( ns , BSON( "name" << 1 << "num" << -1 ) );
conn.done();
+
+ return EXIT_SUCCESS;
}