PDA

View Full Version : How do I get Qt to recognize the oci driver.



yleesun
15th January 2009, 02:12
Now whenever I try to open the database, it says I don't have OCI support. It says I do have the QSQLLite driver but that is it. I look in the /plugins/sqldrivers directory and it has 2 drivers there, the oci and sqllite drivers. How do I get Qt to recognize the oci driver. I have multiple copies of Qt, but I have set everything up to look at the one with the driver. What do I need to do to make Qt recognize the OCI driver? Thanks!!

spirit
15th January 2009, 07:43
put "sqldrivers" directory (with its content) near yours executable.

yleesun
15th January 2009, 07:54
Thanks!
I waited for one day and look for the solution.
My os is solaris 10 and oracle is 10g,I want to known that do these can work tegether?

spirit
15th January 2009, 07:57
what do you mean "I want to known that do these can work tegether?"
I have compiled Qt with OCI under windows and SuSE 11 and on both platforms Qt works fine with Oracle 10g.

yleesun
15th January 2009, 09:12
I mean that weather oracle 10g can work on salaris10.
Could you please tell me how can I use oracel10g on saloris 10.
when i connect to oracle ,it always show warning : oci driver not load.
but I have compiled oracle plugins libqsqloci.so.
How can I make Qt recognize the oci driver?

spirit
15th January 2009, 09:25
did you set path to Oracle lib?

yleesun
15th January 2009, 09:42
the path is:
LD_LIBRARY_PATH=/usr/dt/lib:/usr/lib:/usr/openwin/lib:/usr/local/lib:/export/home/powerDMS/QT4.3.4/lib:/export/home/powerDMS/bin:/usr/sfw/lib:.

spirit
15th January 2009, 10:39
I don't see path to Oracle libs. should be something like this ORACLE_HOME/lib.

yleesun
16th January 2009, 02:32
Thanks!
Now I set the oracle path as this:
LD_LIBRARY_PATH=/usr/dt/lib:/usr/lib:/usr/openwin/lib:/usr/local/lib:/export/home/
powerDMS/QT4.3.4/lib:/usr/sfw/lib:/export/home/oracle/10g/lib:.
But ,it still doesnot work.Driver not loaded!!
Is there anything of QT must be configured?

spirit
16th January 2009, 07:12
try to rebuild OCI plugin again.

seim
18th January 2009, 11:56
To be able to use OCI QtSql driver, you have to have

1) instaled Oracle Instant Client (for g++.ver => 4.1 (i'm not sure now with exact version nr.) use 11g, for older 10g, 10g oracle libraries are compiled with older version of ABI, than newer g++ provides - it could be linkable, but you would get strange behaviour and runtime application sigsegvs); so install rpm packages of: oracle-instantclient-{basic,devel,sqlplus} - it contains base oci libraries and header files you will need to compile QtSql driver

2) create /etc/env.d/99oracle contaning sth. like this ():
ORACLE_HOME=/usr/lib/oracle/10.2.0.3
#ORACLE_SID=
ORACLE_TERM=xterm
ORACLE_OWNER=oracle
TNS_ADMIN=/usr/lib/oracle/10.2.0.3/network/admin
#NLS_LANG=
#ORA_NLS10=
LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.3/client/lib
DISABLE_HUGETLBFS=1
PATH=/usr/lib/oracle/10.2.0.3/client/bin
ROOTPATH=/usr/lib/oracle/10.2.0.3/client/bin
LDPATH=/usr/lib/oracle/10.2.0.3/client/lib:/usr/kde/3.5/lib
TZ=GMT

3) create $TNS_ADMIN/sql.ora
TRACE_LEVEL_CLIENT = OFF
sqlnet.expire_time = 30
NAMES.DIRECTORY_PATH=(TNSNAMES)

4) create $TNS_ADMIN/tnsnames.ora
##connection_identifier## = (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST=dbserver)(PORT= 1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SID=##XE## )))

5) add "##IP## dbserver" to /etc/hosts

6) check connection to your db server with sqlplus: sqlplus user/password@//server[:port]/db_name

7) check connection to your db server with connection_identifier you have set in (4): sqlplus user/password@connection_identifier
=> you need this, because Oracle QtSql driver uses TNSNAMES for connecting to server

8) compile Qt with support of OCI driver; it should be set with some parameter of configurate script + you have to specify also the path to your oracle libraries (sometimes is better to create links from oracle libraries to /lib

9) test connection from your program:
#include <QtCore>
#include <QtDebug>
#include <QtSql>
int main ( int argc, char *argv[] )
{
QCoreApplication app ( argc, argv );
QSqlDatabase db = QSqlDatabase::addDatabase ( "QOCI8", "test_connection" );
db.setDatabaseName ( "connection_identifier" ); // TNS - viz. TNSNAMES.ORA
// db.setHostName ( "" ); // without hn, we use TNS
// db.setPort ( 1521 ); // without port, we use TNS
db.setUserName ( "user" );
db.setPassword ( "password" );
bool ok = db.open();
if (ok)
qDebug("OK.");
else
qDebug("%s", qPrintable(db.lastError().text()));
return 0;
}


I wish you good luck, there are many holes, you can broke your bones with QtSql Oracle driver... (many errors, single thread environment setting, etc.) :cool:

yleesun
19th January 2009, 04:50
Thank you a lot.