mardi 30 août 2022

Returning a Poco session without creating new connection

Depending on if a condition is met I want to return a session but don't want to create a new connection.

Poco::Data::Session initialise(){
 if(some condition){
   Poco::Data::Session temp1('odbc',someSettings1)
   return temp1

  }else{
   Poco::Data::Session temp2('odbc',someSettings2)   
   return temp2
   }
}

int main(){
 Poco::Data::Session  sess(initialise());
}
  1. Does the above create a new connection when I pass the function as a constructor argument?
  2. Would it make a difference if I returned it as an anonymous object i.e. return Poco::Data::Session('odbc',someSettings1)
  3. Or is there a better way overall to achieve what I want?

Aucun commentaire:

Enregistrer un commentaire