After establishing the connection with the following code, there are a few problems
[HTML]View Plaincopy
- Connecting to a database
- Qsqldatabase db = qsqldatabase:: Adddatabase ("Qoci");
- /** Connecting the Oracle Database
- * Database name: ABC
- * Table Name: my_oracle
- * User name: sys
- * Password: 123
- * Port number: (default) 1521
- */
- Db.setport (1521);
- Db.sethostname ("localhost");
- Db.setdatabasename ("abc");
- Db.setusername ("sys");
- Db.setpassword ("123");
- if (!db.open ())
- {
- Link database failed ";
- Db.lasterror (). text ();
- return false;
- }
When you export the contents of Db.lasterror (). Text () to a label, the following questions appear:
1. Prompt: Driver not loaded
Workaround: Copy the folder sqldrivers under the Qt installation directory C:\Qt\Qt5.2.0\5.2.0\Src\qtbase\plugins to your own project file build-linkoracle-desktop_qt_5_2_0_ Mingw_32bit-debug\ theDebug directory.
There are four files in the folder sqldrivers: Libqsqloci.a, LIBQSQLOCID.A, Qsqloci.dll,qsqlocid.dll
2. Prompt: ORA-28009: Should establish the SYS connection unable to logon as SYSDBA identity or sysoper identity
Workaround: Create a new user, connect with the new user, and connect successfully.