Results 1 to 7 of 7

Thread: Oracle Database Connection

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Oracle Database Connection

    I am trying to connect to an Oracle database on Solaris 9. I am using Qt 4.3.0 Commerical Edition. I tried to connect using QOCI but it said I could not do this because I did not have the QOCI driver installed. So I reconfigured Qt and re-made it passing in the -qt-sql-oci flag to the configure script. Then when I tried to connect with the new install of Qt, it still printed out that the drivers are not installed. What would be the problem here? Also, should I be using QOCI or QODBC since I am on Solaris 9? Thanks!

    Edit: I have found out we have Oracle 10g. So I was going to try and build the OCI plugin but I am having problems trying to do this. The docs say to "cd $QTDIR/plugins/src/sqldrivers/oci" but I don't have the directory. The only directory I have is $QTDIR/plugins/src/sqldrivers. Also, my include files and lib files are not located at "INCLUDEPATH+=/usr/include/oracle/10.1.0.3/client/" "LIBS+=-L/usr/lib/oracle/10.1.0.3/client/lib" like it says they should be. So how do I know what to put in for these lines? I am getting this information from here. So how can I install this? Thanks again!
    Last edited by ToddAtWSU; 18th December 2007 at 18:31.

  2. #2
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    1
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Oracle Database Connection

    That must be a typo in the docs. The correct directory should be $QTDIR/src/plugins/sqldrivers/oci.

    The location of the Oracle include and library files depends on your system and your Oracle installation. The paths in the docs are just examples.

  3. The following user says thank you to mm78 for this useful post:

    ToddAtWSU (19th December 2007)

  4. #3
    Join Date
    Feb 2007
    Posts
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Oracle Database Connection

    In the Commercial Qt distribution you should have the oci directory in the src tree.

    In my case, I found it here:


    /usr/local/Trolltech/qt-x11-commercial-src-4.2.3/src/sql/drivers/oci

    It will put the plugin for the driver in the plugins directory of the destination:


    /usr/local/Trolltech/Qt-4.2.3/plugins/sqldrivers/

    I used the configuration parameter -prefix to set the destination:


    -prefix /usr/local/Trolltech/Qt-4.2.3

    Any programs built using qmake and moc from the resulting bin file will use that prefix to find the plugins directory.

    Notice, I did my build under /usr/local/Trolltech and used that as the base of my destination also.

    Now for the oracle, The environment variable $ORACLE_HOME should point to the base of your oracle installation. In my case:


    /ORACLE_HOME=opt/oracle/product/10.1.0/db_1

    This intern I used the configuration parameters


    -I /opt/oracle/product/10.1.0/db_1/rdbms/public

    and

    -L /opt/oracle/product/10.1.0/db_1/lib

    Just to make all of this clear, my configure line looked like this in the end:


    configure -prefix /usr/local/Trolltech/Qt-4.2.3 -I /usr/include/pgsql \
    -I /opt/oracle/product/10.1.0/db_1/rdbms/public \
    -L /opt/oracle/product/10.1.0/db_1/lib -qt-gif -qt-libpng -qt \
    -libmng -qt-libjpeg -plugin-sql-psql -plugin-sql-oci -qt-gif

    At run time I had to add the directories to my LD_LIBRARY_PATH. It looks like:


    LD_LIBRARY_PATH=:/opt/oracle/product/10.1.0/db_1/lib:/usr/local/Trolltech/Qt-4.2.0/lib

    The versions in the paths may vary from yours but the overall structures remain reasonably constant.

    Now if I can only make it work for Windows using MVC

  5. The following user says thank you to croftj for this useful post:

    ToddAtWSU (19th December 2007)

  6. #4
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Oracle Database Connection

    I can't wait to try this. I will set this up to run overnight and try it again. But one question I have is there a reason you chose to do -plugin-sql-oci instead of -qt-sql-oci? Thanks!

  7. #5
    Join Date
    Feb 2007
    Posts
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Oracle Database Connection

    Not in particular. I've been tempted to try just compiling it in, but haven't had the need at this point to revisit it.

  8. #6
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Cool Re: Oracle Database Connection

    I was able to manually build the driver on my own. I went to the $QTDIR/src/plugins/sqldrivers/oci directory. I then ran

    $QTDIR/bin/qmake -o Makefile "INCLUDEPATH+=$ORACLE_HOME/rdbms/public" "LIBS+=-L$ORACLE_HOME/lib32" oci.pro

    Then I ran make and it all worked well. The library was copied into $QTDIR/plugins/sqldrivers.

    Inside my program's makefile I added these lines and also modified my LD_LIBRARY_PATH inside my .cshrc and re-sourced the .cshrc:

    In the INC variable I added the line: -I$(QT)/include/QtSql
    In the LIBS variable I added the line: -lQtSql
    In the LIBHOMES variable I added the line: -L$(QT)/plugins/sqldrivers

    I did a make clean followed by a make and everything compiled and linked correctly. But when I ran the program and tried to create a QSqlDatabase I got some printout errors. I first tried to create the database with the line

    Qt Code:
    1. QSqlDatabase db = QSqlDatabase( "QOCI" );
    To copy to clipboard, switch view to plain text mode 

    The errors that print out are:

    QSqlDatabase: QOCI driver not loaded
    QSqlDatabse: available drivers:
    According to this there are no database drivers installed anywhere. Is there something else I need to do to let the program or Qt know I made the QOCI driver? Thanks!

  9. #7
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Oracle Database Connection

    Looking at other posts, it seems I have to make a QApplication to get the plugins. Is this correct? I will look into doing this. Thanks!

    Edit: Well I added the QApplication creation call into my main. I made it the VERY first line in main so it would be created right away. 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!!
    Last edited by ToddAtWSU; 20th December 2007 at 16:00.

Similar Threads

  1. Threads and database connection
    By probine in forum Qt Programming
    Replies: 9
    Last Post: 7th August 2013, 08:30
  2. Client/Server Error: BadIDChoice
    By 3nc31 in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2007, 10:22
  3. Insertion of unicode characters into database oracle through pro c
    By hemananda choudhuri in forum Qt Programming
    Replies: 1
    Last Post: 8th January 2007, 10:42
  4. Qt and MySQL Database Connection
    By shamik in forum Qt Programming
    Replies: 41
    Last Post: 6th October 2006, 12:48
  5. Oracle Database Problem
    By magikalpnoi in forum Qt Programming
    Replies: 3
    Last Post: 27th September 2006, 21:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.