试图使用OTL连接到我的PostgreSQL服务器
Trying to use OTL to connect to my PostgreSQL server
我正在尝试连接我的c++客户端到PostgreSQL数据库。我一直得到otlv4.h|12406|对' SQLFreeHandle@8'的未定义引用和许多其他未定义引用错误。
要获取头文件请访问http://otl.sourceforge.net/otl3_down.htm
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// #define OTL_ODBC_UNIX // uncomment this line if UnixODBC is used
#define OTL_ODBC_ALTERNATE_RPC
#if !defined(_WIN32) && !defined(_WIN64)
#define OTL_ODBC
#else
#define OTL_ODBC_POSTGRESQL // required with PG ODBC on Windows
#endif
#include "otlv4.h" // include the OTL 4.0 header file
otl_connect db; // connect object
int main()
{
otl_connect::otl_initialize(); // initialize ODBC environment
db.rlogon("postgres/changeme@numbers");
db.commit();
cout << "Hello world!" << endl;
db.logoff(); // disconnect from ODBC
return 0;
}
当我使用ODBC从Windows连接到PostgreSQL时,我使用了较少的dsn方法。从用户的角度来看,它不需要任何输入——用户不需要知道什么是ODBC以及如何配置ODBC源(DSN)。
使用无dns连接的典型方法是使用如下字符串作为您的ODBC连接字符串:
Driver=PostgreSQL;Server=hostname;Database=mypgdb;UID=username;PWD=password
请注意,驱动程序名称可能需要根据版本和ANSI与Unicode口味进行调整。
相关文章:
- 我的神经网络不起作用 [XOR 问题]
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 我的字符计数代码计算错误.为什么
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- cmake在我的项目中所需的所有静态库都不成功
- 为什么我的代码在输出中增加了93天
- 我的简单if-else语句是如何无法访问的代码
- 为什么我的for循环不能正确获取argv
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 0-1背包代码中的错误.我的代码中有什么错误
- 当我的阵列太大时出现分段错误
- 如何确认我的constexpr表达式实际上已经在编译时执行
- 为什么二进制搜索在我的测试中不起作用
- 如何指定我希望我的LIB链接到的DLL文件?-Visual Studio 2019
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 当我在main中声明了我的2d数组时,为什么我的程序会退出
- OpenGL在启用深度测试时不会丢弃我的碎片
- 为什么我的 std::ref 无法按预期工作?
- PostgreSQL:如何为我的单元测试创建临时用户和数据库
- 试图使用OTL连接到我的PostgreSQL服务器