Home >Database >Mysql Tutorial >Qt远程连接Oracle数据库

Qt远程连接Oracle数据库

WBOY
WBOYOriginal
2016-06-07 17:22:022225browse

一:代码 /**连接Oracle数据库 *数据库名:abc *表名:my_oracle *用户名:system *密码:123 *端口号:(默认)

一:代码

二:连接过程遇到的问题。

问题1:

QSqlDatabase: QOCI driver not loaded

QSqlDatabase:available drivers: QSQLITE QODBC3 QODBC
(1)出错原因:本连接是通过QMYSQL驱动,而Qt本身并没有QOCI驱动(只有QSQLITE QODBC3 QODBC),

      所以就需要自己编译QOCI。

(2)编译QOCI驱动。

  1.go to "Qt Command Prompt" window. (开始-程序-对应的qt项里面去找)。

  2.qmake "INCLUDEPATH+=c:\oracle\oci\include" "LIBS+=-Lc:\oracle\oci\lib\msvc" oci.pro

  3.qmake "INCLUDEPATH+=D:\oracle_setup\app\admin\product\11.1.0\db_3\OCI\include" "LIBS+=-LD:\oracle_setup\app\admin\product\11.1.0\db_3\OCI\lib\msvc" oci.pro

  4.mingw32-make

问题2:

出现错误:

D:\qt_sdk\qt\src\plugins\sqldrivers\oci>mingw32-make
mingw32-make -f Makefile.Debug all
mingw32-make[1]: Entering directory `D:/qt_sdk/qt/src/plugins/sqldrivers/oci'
mingw32-make[1]: Nothing to be done for `all'.
mingw32-make[1]: Leaving directory `D:/qt_sdk/qt/src/plugins/sqldrivers/oci'
mingw32-make -f Makefile.Release all
mingw32-make[1]: Entering directory `D:/qt_sdk/qt/src/plugins/sqldrivers/oci'
mingw32-make[1]: Nothing to be done for `all'.
mingw32-make[1]: Leaving directory `D:/qt_sdk/qt/src/plugins/sqldrivers/oci'

出错原因:这个问题表示QOCI驱动已经被编译过了!

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn