title: Connection to Postgres Database using libpqxx
body: <p>I am using libpqxx to connect to a postgres database by creating a class.</p>
  
  <pre><code>class databaseConnection
  {
  public:
      pqxx::connection* conn;
      void SetConnection(){
          conn=new pqxx::connection(
              "username=temp "
              "host=db.corral.tacc.utexas.edu "
              "password=timelione "
              "dbname=temp");
  
      }
  
      void Disconnect(){
          conn-&gt;disconnect();
      }
  
      pqxx::result query(std::string strSQL){
          //SetConnection();
          pqxx::work trans(*conn,"trans");
  
          pqxx::result res=trans.exec(strSQL);
  
          trans.commit();
          return res;
      }
  };
  
  int main()
  {
      databaseConnection* pdatabase;
      pdatabase-&gt;SetConnection();
      return 0;
  }
  </code></pre>
  
  <p>I am getting error that says  </p>
  
  <pre><code>terminate called after throwing an instance of 'pqxx::broken_connection' 
  what(): invalid connection option "database"
  </code></pre>
  
  <p>Can anyone help me out?</p>
  
  <p>Thanks</p>