Results 1 to 19 of 19

Thread: QOCIDriver: unable to create environment

  1. #1
    Join Date
    Dec 2011
    Posts
    33
    Thanks
    56
    Qt products
    Qt4
    Platforms
    Windows

    Default QOCIDriver: unable to create environment

    Hi verybody.
    I'm trying to connect Oracle Database using QOCI Driver.
    I used QT Eclipse Plugin + MINGW + Eclipse C++ + Window 7.

    I complied OCI.DLL success.
    But when I run my code here:
    Qt Code:
    1. #include <QApplication>
    2. #include <QtSql>
    3. #include <QtPlugin>
    4.  
    5.  
    6. #include <iostream>
    7. using namespace std;
    8.  
    9. /* Change these to match your database */
    10. #define HOST "127.0.0.1"
    11. #define DB "xe"
    12. #define PORT 1521
    13. #define USER "testbed"
    14. #define PASSWD "secre3t"
    15.  
    16. int main(int argc, char *argv[])
    17. {
    18. QApplication app(argc, argv);
    19.  
    20.  
    21. // QSqlDatabase db = QSqlDatabase::addDatabase(ociDriver->create("QOCI"));
    22.  
    23. QSqlDatabase qDB = QSqlDatabase::addDatabase("QOCI");
    24.  
    25. qDB.setHostName(HOST);
    26. qDB.setDatabaseName(DB);
    27. qDB.setPort(PORT);
    28. qDB.setUserName(USER);
    29. qDB.setPassword(PASSWD);
    30.  
    31. /* Probably overkill ;) */
    32. qDB.setConnectOptions("Prefetch_Memory=5242880;Prefetch_Rows=250");
    33.  
    34. if (qDB.open() == FALSE) {
    35. cout<< "Error: opening DB failed because " << qDB.lastError().text().toStdString();
    36. return -1;
    37. }
    38.  
    39.  
    40. return 0;
    41. }
    To copy to clipboard, switch view to plain text mode 

    Errors:
    QOCIDriver: unable to create environment
    QOCIDriver:: parseArgs: Invalid parameter: 'Prefetch_Memory'
    QOCIDriver:: parseArgs: Invalid parameter: 'Prefetch_Rows'
    Unable to free Error handle: -1
    Unable to free Environment handle: -1


    I set variables enviroment here:
    Name: Path
    Value: C:\oraclexe\app\oracle\product\11.2.0\server\bin;; C:\app\nguyenluuvu\product\11.2.0\client;C:\app\ng uyenluuvu\product\11.2.0\client_1\bin;E:\app\nguye nluuvu\product\11.2.0\client_1;C:\app\MAY02\produc t\11.2.0\dbhome_1\bin;%SystemRoot%\system32;%Syste mRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\Sys tem32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Prog ram Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\TortoiseHg\;C:\MinGW\bin\; C:\msys\1.0\bin\;C:\luuvu\MinGW\bin;C:\Program Files\CMake 2.8\bin;C:\luuvu\qt\bin;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\OPENCV;C:\App\nguyenluuvu\product\11.2.0\cli ent_1\oci\include;C:\App\nguyenluuvu\product\11.2. 0\client_1\oci\lib\msvc;C:\Windows\System32;C:\luu vu\qt\plugins\sqldrivers\qopenocci.dll;C:\oraclexe \app\oracle\product\11.2.0\instantclient_11_2;C:\o raclexe\app\oracle\product\11.2.0\server\bin;C:\Wi ndows\System32;C:\oraclexe\app\oracle\product\11.2 .0\server\oci\lib\MSVC;C:\oraclexe\app\oracle\prod uct\11.2.0\server\oci\include



    Can you help me?
    Thanks so much!
    Last edited by thaihoangluu; 8th May 2012 at 09:04.
    Nguyá»…n LÆ°u VÅ© - Http://nguyenluuvu.com

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QOCIDriver: unable to create environment

    The errors generated by line 32 are self-explanatory, your options do not appear in the list here: QSqlDatabase::setConnectOptions()

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

    thaihoangluu (10th May 2012)

  4. #3
    Join Date
    Dec 2011
    Posts
    33
    Thanks
    56
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QOCIDriver: unable to create environment

    Nguyá»…n LÆ°u VÅ© - Http://nguyenluuvu.com

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QOCIDriver: unable to create environment

    You don't say whether the database connection opens or not. The first line is a Qt warning, not an error. The warning results when OCIEnvCreate() (not a Qt function) fails. A quick search suggests this is either an incorrect ORACLE_HOME or permissions related: can your user read the directories under ORACLE_HOME?

  6. The following user says thank you to ChrisW67 for this useful post:

    thaihoangluu (10th May 2012)

  7. #5
    Join Date
    Dec 2011
    Posts
    33
    Thanks
    56
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QOCIDriver: unable to create environment

    Quote Originally Posted by ChrisW67 View Post
    You don't say whether the database connection opens or not. The first line is a Qt warning, not an error. The warning results when OCIEnvCreate() (not a Qt function) fails. A quick search suggests this is either an incorrect ORACLE_HOME or permissions related: can your user read the directories under ORACLE_HOME?

    Qt Code:
    1. #include <QtCore>
    2. #include <QtSql>
    3. #include <QSqlDatabase>
    4.  
    5. #include <iostream>
    6.  
    7. using namespace std;
    8.  
    9. int main(int argc, char *argv[])
    10. {
    11. QSqlDatabase qdb = QSqlDatabase::addDatabase("QOCI");//If I replace "QOCI" = "QODBC" -> It's okay.
    12.  
    13. qdb.setHostName("localhost");
    14. qdb.setDatabaseName("test");
    15. qdb.setUserName("postgres");
    16. qdb.setPassword("1234");
    17. qdb.setPort(1521);
    18.  
    19. if(qdb.open())
    20. {
    21. cout << "Database connection successful!" << endl;
    22. }
    23. else
    24. {
    25. cout << "Database connection not successful!" << endl;
    26. }
    27.  
    28. qdb.close();
    29. return 0;
    30. }
    To copy to clipboard, switch view to plain text mode 

    How to fix error QOCIDriver: unable to create environment .Hizzzz
    Nguyá»…n LÆ°u VÅ© - Http://nguyenluuvu.com

  8. #6
    Join Date
    Dec 2011
    Posts
    33
    Thanks
    56
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QOCIDriver: unable to create environment

    Dear ChrisW67
    Can you help me? Please !
    Nguyá»…n LÆ°u VÅ© - Http://nguyenluuvu.com

  9. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QOCIDriver: unable to create environment

    I already have...
    The warning results when OCIEnvCreate() (not a Qt function) fails. A quick search suggests this is either an incorrect ORACLE_HOME or permissions related: can your user read the directories under ORACLE_HOME?
    Have you checked these things?

  10. The following user says thank you to ChrisW67 for this useful post:

    thaihoangluu (10th May 2012)

  11. #8
    Join Date
    Dec 2011
    Posts
    33
    Thanks
    56
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QOCIDriver: unable to create environment

    Quote Originally Posted by ChrisW67 View Post
    I already have...


    Have you checked these things?
    How do you define Oracle_Home -> i don't know this.
    Sorry if my question stupid

    Do you guide me with image?
    thanks so much.
    Nguyá»…n LÆ°u VÅ© - Http://nguyenluuvu.com

  12. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QOCIDriver: unable to create environment

    ORACLE_HOME is an environment variable, or on Windows a registry entry, that almost all Oracle utilities use to find, among other things, the Oracle client and connection information files. ORACLE_HOME has nothing to do with Qt specifically and is set outside your program. ORACLE_HOME is generally set by the Oracle client installer. I suggest you need to consult your Oracle DBA or Oracle documentation.

    http://www.orafaq.com/wiki/ORACLE_HOME

  13. The following user says thank you to ChrisW67 for this useful post:

    thaihoangluu (10th May 2012)

  14. #10
    Join Date
    Dec 2011
    Posts
    33
    Thanks
    56
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QOCIDriver: unable to create environment

    Thank you.
    I set varible environment :
    Name: ORACLE_HOME
    Value: C:\oraclexe\app\oracle\product\11.2.0\server

    But it's error
    Nguyá»…n LÆ°u VÅ© - Http://nguyenluuvu.com

  15. #11
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QOCIDriver: unable to create environment

    Take the "/server" off the end. The example in the FAQ I linked stops at the version numbered folder. You should be able to find a folder "bin" (usually contains sqlplus) in the folder pointed to by ORACLE_HOME.
    Last edited by ChrisW67; 10th May 2012 at 05:49.

  16. The following user says thank you to ChrisW67 for this useful post:

    thaihoangluu (10th May 2012)

  17. #12
    Join Date
    Dec 2011
    Posts
    33
    Thanks
    56
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QOCIDriver: unable to create environment

    Quote Originally Posted by ChrisW67 View Post
    Take the "/server" off the end. The example in the FAQ I linked stops at the version numbered folder. You should be able to find a folder "bin" (usually contains sqlplus) in the folder pointed to by ORACLE_HOME.
    I tried all suggest , but it's nothing to effective



    It's my HOME PATH ORACLE FOLDER.
    a.jpg
    Can you tell me Set variable environtment please?
    Nguyá»…n LÆ°u VÅ© - Http://nguyenluuvu.com

  18. #13
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QOCIDriver: unable to create environment

    Where is sqlplus.exe? Ignoring your program for the time being, can sqlplus connect to your database?

    I do not propose to download and install an entire RDBMS just to answer your question.

  19. #14
    Join Date
    Dec 2011
    Posts
    33
    Thanks
    56
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QOCIDriver: unable to create environment

    Quote Originally Posted by ChrisW67 View Post
    Where is sqlplus.exe? Ignoring your program for the time being, can sqlplus connect to your database?

    I do not propose to download and install an entire RDBMS just to answer your question.
    I don't know @@
    I have followed all instructions but when running any program error!!!!
    Nguyá»…n LÆ°u VÅ© - Http://nguyenluuvu.com

  20. #15
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QOCIDriver: unable to create environment

    I know your program generates error messages, you do not need to keep saying that. The situation will not change until you start applying some effort to identifying the problem.

  21. The following user says thank you to ChrisW67 for this useful post:

    thaihoangluu (10th May 2012)

  22. #16
    Join Date
    Dec 2011
    Posts
    33
    Thanks
    56
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QOCIDriver: unable to create environment

    Quote Originally Posted by ChrisW67 View Post
    I know your program generates error messages, you do not need to keep saying that. The situation will not change until you start applying some effort to identifying the problem.
    I connect MS SQL Server successfully but connect Oracle is very Complex @@
    Nguyá»…n LÆ°u VÅ© - Http://nguyenluuvu.com

  23. #17
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QOCIDriver: unable to create environment

    No, the Oracle client software needs to be installed correctly to be used. This is no different to the Microsoft SQL Server client, except that Microsoft install it with Windows.

    How have you installed the Oracle client software? Do any of the Oracle utilities function for connecting to the database?

  24. #18
    Join Date
    Dec 2011
    Posts
    33
    Thanks
    56
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QOCIDriver: unable to create environment

    Quote Originally Posted by ChrisW67 View Post
    No, the Oracle client software needs to be installed correctly to be used. This is no different to the Microsoft SQL Server client, except that Microsoft install it with Windows.

    How have you installed the Oracle client software? Do any of the Oracle utilities function for connecting to the database?

    How to install Oracle correctly?

    Step 1: I install Oracle Database Express Edition 11g Release 2. http://www.oracle.com/technetwork/pr...eSiteId=ocomen

    Step 2: I install Instant Client Downloads.http://www.oracle.com/technetwork/da...eSiteId=ocomen

    Am I correct?

    If I false please guide me Install Oracle.

    Thanks and sorry if My English is bad
    Nguyá»…n LÆ°u VÅ© - Http://nguyenluuvu.com

  25. #19
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QOCIDriver: unable to create environment

    Quote Originally Posted by Me
    Where is sqlplus.exe? Ignoring your program for the time being, can sqlplus connect to your database?
    Quote Originally Posted by Me
    Do any of the Oracle utilities function for connecting to the database?
    This is the last time I will ask:
    Do any of the Oracle supplied utilities work to connect to your database?

Similar Threads

  1. Unable to create qwtPlot object
    By jtso8 in forum Qwt
    Replies: 7
    Last Post: 23rd January 2012, 06:43
  2. Visual Studio 2010 Add-In - unable to create project
    By garaddon in forum Installation and Deployment
    Replies: 2
    Last Post: 1st January 2011, 11:40
  3. Eclipse debugging: Unable to create variable object
    By PUK_999 in forum Installation and Deployment
    Replies: 0
    Last Post: 20th August 2009, 21:42
  4. Unable to successfully create Qt application
    By remy06 in forum Qt Programming
    Replies: 1
    Last Post: 25th April 2009, 13:51
  5. QSQLITE Unable to fetch row in create
    By xgoan in forum Newbie
    Replies: 3
    Last Post: 18th October 2006, 14:39

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.