'How to connect to oracle cloud database from Qt5

Can someone help me with the connection to the Oracle Cloud from Qt.

I can't find any information on the Qt website, nor examples, but surely someone has wanted to connect to an instance of autonomous data base, with Qt.

I already connect with SqlDeveloper, with SqlCl, I just need to be able to do it with Qt, because I can't find the way

Thank you very much !



Solution 1:[1]

I finally managed to get it working. The code is the following:

extern int      QtConnection(int argc, char *argv[])
{
    QCoreApplication a();
    
    QSqlDatabase db = QSqlDatabase::addDatabase("QOCI", "conn_name"); 
    
    db.setDatabaseName("database");
    db.setUserName("eternumx");
    db.setPassword("12345678");
    db.setConnectOptions("OCI_ATTR_PREFETCH_ROWS=1000"); 

    if (db.isValid())
    {   
        db.open();

        if (!db.isOpen())
        {   
            qDebug() << db.lastError().text().toLatin1().data() << endl;
            return 0;
        }   
    }   
    else
    {   
        qDebug() << db.lastError().text().toLatin1().data() << endl;
        return 0;
    }   

    return 1;
}

Then configure the environment variables TNS_ADMIN (for which the program finds the sqlnet.ora and tnsnames.ora files) and the sqlnet.ora file that indicates where the wallet is. worked perfectly

Solution 2:[2]

Assuming that your code base is a client server application written in C++, you would probably want to use occi to natively access your Oracle Database.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Viru Yuale
Solution 2 doberkofler