0

私はデータベースを使用するのが初めてです。私はOracle SQLを学んでおり、サイトからOracle Express Edition 18cをインストールしました。私は通常、提供されている SQL*Plus ツールを使用して SQL クエリを実行します。今、プロジェクトの C++ プログラムからデータベースに接続できるようにしたいと思っています。odbc について聞いたので、自分のオラクル バージョン用の odbc ドライバーとインスタント クライアントを彼らのサイトからダウンロードしました。次に、C++ を使用してデータベースに接続するために使用できる SQLAPI++ というサードパーティ ライブラリを見つけました。ライブラリをダウンロードしてプロジェクトに含めました。Windows 10でcodeblocks IDEを使用しています。このプログラムを実行して、データベースに接続できるかどうかをテストしようとしました-

#include<iostream>
#include<SQLAPI.h>

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<<"Connected successfully"<<endl;
            conn.Disconnect();
            cout<<"Disconnected successfully"<<endl;
        }
        else
            cout<<"Failed to connect"<<endl;
    }
    catch(SAException &a)
    {

        cout<<endl<<a.ErrText().GetMultiByteChars()<<endl;
    }
}

コンパイラ エラーや警告はありません。現在、「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__+306>) 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

4

2 に答える 2