【问题标题】:Exception during connecting to postgresql database using wt c++ library?使用 wt c++ 库连接到 postgresql 数据库时出现异常?
【发布时间】:2015-05-09 15:30:42
【问题描述】:

我正在尝试连接到名为“galaxydatabase”的 postgresql 数据库,但遇到了未处理的异常。 源代码:

#include <Wt/Dbo/Dbo>
#include <Wt/Dbo/backend/Postgres>

namespace dbo = Wt::Dbo;

void run()
{
    dbo::backend::Postgres po;
    po.connect("galaxydatabase");
    // or
    //dbo::backend::Postgres po("galaxydatabase"); // the same exception???
}

int main(int argc, char **argv)
{
    run();
}

【问题讨论】:

  • 您收到的确切例外情况是什么?

标签: c++ database postgresql wt


【解决方案1】:

connect() 需要一个 PostgreSQL 连接字符串,例如"host=127.0.0.1 user=test password=test port=5432 dbname=test"。您可以根据需要提供不同的参数,不需要的可以省略。

The PostgreSQL documentation 有更多关于允许哪些参数以及它们的作用。

【讨论】:

    猜你喜欢
    • 2016-04-23
    • 1970-01-01
    • 2013-04-19
    • 2023-04-01
    • 1970-01-01
    • 2019-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多