我正在使用libpqxx来创建一个类连接到Postgres数据库。
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->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->SetConnection();
return 0;
}
我遇到了一种错误,提示如下:
terminate called after throwing an instance of 'pqxx::broken_connection'
what(): invalid connection option "database"
有人能帮我吗?
谢谢