c++连接oracle数据库程序,无法从c++程序连接到我的oracle数据库

我对使用数据库有点陌生。我一直在学习oraclesql,并在他们的网站上安装了oraclexpressedition18c。我通常通过提供的sql*Plus工具执行sql查询。现在,我真的很想能够从我的c++程序连接到一个项目的数据库。我听说了odbc,于是从他们的网站上下载了odbc驱动程序和oracle版本的即时客户端。然后我发现了一个第三方库,名为SQLAPI++,可以用来用c++连接到数据库。我下载了这个库并将其包含在我的项目中。我在Windows10上使用代码块IDE。我试着运行这个程序来测试我是否可以连接到数据库-

#include

#include

using namespace std;

int main()

{

SAConnection conn;

try

{

conn.Connect("Data Source=LIBRARY;User Id=my_uid;Password=my_pass;Integrated Security=no","my_uid","my_pass",SA_Oracle_Client);

//LIBRARY is my dsn that i created by using the odbc 64-bit admin. tool in the user dsn tab. I used the "Oracle in instantclient_18_5" driver for it.

if(conn.isConnected()==TRUE)

{

cout<

conn.Disconnect();

cout<

}

else

cout<

}

catch(SAException &a)

{

cout<

}

}

没有编译器错误或警告。现在它打印出--“ORA-12154:TNS:无法解析指定的连接标识符”。任何帮助都将不胜感激!><

编辑:现在我运行了调试器,这就是我看到的-

Setting breakpoints

Debugger name and version: GNU gdb (GDB) 7.9.1

Child process PID: 15224

In __cxa_throw () ()

1094 oraAPI.cpp: No such file or directory.

#1 0x00494eb2 in oraAPI::Check (this=0x1307fe8, sCommandText=..., status=-1, hndlp=0x95f208, type=2, pOCIStmt=0x0) at oraAPI.cpp:1094

In __cxa_get_globals () ()

#3 0x00494c06 in oraAPI::Check (this=0x1307fe8, status=-1, hndlp=0x95f208, type=2, pOCIStmt=0x0) at oraAPI.cpp:1018

1018 in oraAPI.cpp

Cannot open file: ../../../../../src/gcc-5.1.0/libgcc/unwind-sjlj.c

At ../../../../../src/gcc-5.1.0/libgcc/unwind-sjlj.c:126

Cannot open file: ../../../../../src/gcc-5.1.0/libgcc/unwind-sjlj.c

At ../../../../../src/gcc-5.1.0/libgcc/unwind-sjlj.c:128

In __cxa_get_globals () ()

1730 SQLAPI.cpp: No such file or directory.

#7 0x004054bb in SAConnection::NativeAPI (this=0x5710b2 <__dtor_list__>) at SQLAPI.cpp:1730

In __cxa_throw () ()

1018 oraAPI.cpp: No such file or directory.

#2 0x00494c06 in oraAPI::Check (this=0x1307fe8, status=-1, hndlp=0x95f208, type=2, pOCIStmt=0x0) at oraAPI.cpp:1018

[Inferior 1 (process 15224) exited normally]

Debugger finished with status 0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值