Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void SaveDoc(DBClientConnection &conn)
- {
- b.append("data", data);
- BSONObj p = b.obj();
- if (conn.isFailed()==false){
- try{
- conn.insert("db.collection",p);
- } catch (std::exception& e)
- {
- std::cerr << "Exception occured while inserting log: " << e.what() << "\n";
- }
- } else {
- cout<<"Not connected to DB!"<<endl;
- try{
- cout<<"Trying to re-connect to DB"<<endl;
- conn.connect("localhost"); }
- catch (std::exception& e)
- {
- cout<< "Exception found while reconnecting: " << e.what() << "\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement