Thread: SQLAPI++ library

  1. #31
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    I seem to be getting an unhandled exception though... Throws an exception when trying to connect... My Username : example Password : example Conn : XE are all correct because i can access the DB

  2. #32
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    That's where all this try/catch code comes in handy:
    Code:
        // Make sure we get a connection to the database in question, otherwise quit.
    try
    {
        cout << "Enter password for user YOUR_USER_HERE: ";
        cin >> strPass;
        conn = env->createConnection(strUser,strPass,strConn);
    }
    catch (SQLException &sqlExcp)
    {
        cerr << sqlExcp.getErrorCode() << ": " << sqlExcp.getMessage()
             << "Press a key to continue..." << endl;
        cin.ignore();						// Ignore previous ws
        cin.get();
        Environment::terminateEnvironment(env);
        return EXIT_FAILURE;
    }
    Can you post a small sample of your code, at least the code around where you attempt to do the env->CreateConnection call?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #33
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by hk_mp5kpdw View Post
    That's where all this try/catch code comes in handy:
    Code:
        // Make sure we get a connection to the database in question, otherwise quit.
    try
    {
        cout << "Enter password for user YOUR_USER_HERE: ";
        cin >> strPass;
        conn = env->createConnection(strUser,strPass,strConn);
    }
    catch (SQLException &sqlExcp)
    {
        cerr << sqlExcp.getErrorCode() << ": " << sqlExcp.getMessage()
             << "Press a key to continue..." << endl;
        cin.ignore();						// Ignore previous ws
        cin.get();
        Environment::terminateEnvironment(env);
        return EXIT_FAILURE;
    }
    Can you post a small sample of your code, at least the code around where you attempt to do the env->CreateConnection call?
    Code:
    Environment * env = Environment::createEnvironment();
        Connection * conn = NULL;
        const string strUser = "example";       // User we connect as
        const string strConn = "XE";   // Database connection
        string strPass;                                // Password for above
    
        // Make sure we get a connection to the database in question, otherwise quit.
        try
        {
            cout << "Enter password for user YOUR_USER_HERE: ";
            cin >> strPass;
            conn = env->createConnection(strUser,strPass,strConn);
        }
        catch (SQLException &sqlExcp)
        {
            cerr << sqlExcp.getErrorCode() << ": " << sqlExcp.getMessage()
    			 << "Press a key to continue..." << endl;
            cin.ignore();						// Ignore previous ws
            cin.get();
            Environment::terminateEnvironment(env);
            return EXIT_FAILURE;
        }
    The red part doesn't print "Press a key to continue" instead i get 24960: printed and a Microsoft DEBUG error window with don't send/send error options ... I think it throws an exception on the red part

  4. #34
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by csonx_p View Post
    Code:
    Environment * env = Environment::createEnvironment();
        Connection * conn = NULL;
        const string strUser = "example";       // User we connect as
        const string strConn = "XE";   // Database connection
        string strPass;                                // Password for above
    
        // Make sure we get a connection to the database in question, otherwise quit.
        try
        {
            cout << "Enter password for user YOUR_USER_HERE: ";
            cin >> strPass;
            conn = env->createConnection(strUser,strPass,strConn);
        }
        catch (SQLException &sqlExcp)
        {
            cerr << sqlExcp.getErrorCode() << ": " << sqlExcp.getMessage()
    			 << "Press a key to continue..." << endl;
            cin.ignore();						// Ignore previous ws
            cin.get();
            Environment::terminateEnvironment(env);
            return EXIT_FAILURE;
        }
    The red part doesn't print "Press a key to continue" instead i get 24960: printed and a Microsoft DEBUG error window with don't send/send error options ... I think it throws an exception on the red part
    "Unhandled exception at 0x104f1795 (msvcp80d.dll) in dbtester.exe: 0xC0000005: Access violation reading location 0xcccccccc."

  5. #35
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    What's your TNS_NAMES file look like (if you don't mind ...you can omit stuff like IP addresses)?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  6. #36
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by hk_mp5kpdw View Post
    What's your TNS_NAMES file look like (if you don't mind ...you can omit stuff like IP addresses)?
    Code:
    XE =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = officepc)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = XE)
        )
      )
    
    EXTPROC_CONNECTION_DATA =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
        )
        (CONNECT_DATA =
          (SID = PLSExtProc)
          (PRESENTATION = RO)
        )
      )
    
    ORACLR_CONNECTION_DATA = 
      (DESCRIPTION = 
        (ADDRESS_LIST = 
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE)) 
        ) 
        (CONNECT_DATA = 
          (SID = CLRExtProc) 
          (PRESENTATION = RO) 
        ) 
      )

    i didn;t specify any ip address anywhere AFAIC

  7. #37
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    I think this might be a DLL issue... since the code seems to compile/link fine. In the instructions for downloading/installing the library code you were instructed to unzip the Oracle libraries somewhere (there should have been some DLLs for you to download [or maybe they came with everything else] as well). Can you verify all the libraries .LIB and .DLL that you've downloaded. Also there were those instructions to put the location (the folder path) of the .DLL files into your path environment variable. Did you do that?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  8. #38
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by hk_mp5kpdw View Post
    I think this might be a DLL issue... since the code seems to compile/link fine. In the instructions for downloading/installing the library code you were instructed to unzip the Oracle libraries somewhere (there should have been some DLLs for you to download [or maybe they came with everything else] as well). Can you verify all the libraries .LIB and .DLL that you've downloaded. Also there were those instructions to put the location (the folder path) of the .DLL files into your path environment variable. Did you do that?
    unzipped to C:\oraclexe\app\oracle\product\10.2.0\server\OCI\l ib\MSVC\Vc8
    got the needed lib/dll there ... went to project properties and added other dependencies pointing to this path

  9. #39
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by hk_mp5kpdw View Post
    I think this might be a DLL issue... since the code seems to compile/link fine. In the instructions for downloading/installing the library code you were instructed to unzip the Oracle libraries somewhere (there should have been some DLLs for you to download [or maybe they came with everything else] as well). Can you verify all the libraries .LIB and .DLL that you've downloaded. Also there were those instructions to put the location (the folder path) of the .DLL files into your path environment variable. Did you do that?
    How do i attach files here? would like to show you my project environmental settings ....

  10. #40
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Project properties and the dependencies takes care of the .lib issues and linking. Setting up the PATH such that the folder where the .dll files are is included takes care of those (according to the instructions) They are probably in the same location so your first PATH setting should also be pointing to that same folder as in your project's "Additional Library Directories". You should have the following LIB/DLLs present wherever they may be:
    oci.dll
    ocijdbc.dll
    ociw32.dll
    orannzsbb10.dll
    oraocci10.dll
    oraocci10.lib
    oraocci10d.dll
    oraocci10d.lib
    oraociei10.dll
    I've also got a couple other files in that directory for whatever reason:
    classes12.jar
    occivc8_102030_Readme.txt
    ojdbc14.jar
    oraocci10.dll.manifest
    oraocci10d.dll.manifest
    Quote Originally Posted by csonx_p
    How do i attach files here? would like to show you my project environmental settings ....
    When you click on Post Reply, there is an area titled "Additional Options" with a "Manage Attachments" button. Click on that button and another pop-up window should appear where you can browse files on your computer and then click on the "Upload" button for each file you wish to attach. When you're done with all the files you want to attach you can close the pop-up window with the "Close this Window" button. When you finally post, those files will be attached to your post.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  11. #41
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by hk_mp5kpdw View Post
    Project properties and the dependencies takes care of the .lib issues and linking. Setting up the PATH such that the folder where the .dll files are is included takes care of those (according to the instructions) They are probably in the same location so your first PATH setting should also be pointing to that same folder as in your project's "Additional Library Directories". You should have the following LIB/DLLs present wherever they may be:

    I've also got a couple other files in that directory for whatever reason:



    When you click on Post Reply, there is an area titled "Additional Options" with a "Manage Attachments" button. Click on that button and another pop-up window should appear where you can browse files on your computer and then click on the "Upload" button for each file you wish to attach. When you're done with all the files you want to attach you can close the pop-up window with the "Close this Window" button. When you finally post, those files will be attached to your post.
    this statement ...
    Code:
    sqlExcp.getMessage()
    its what's throwing "Access violation reading location 0xcccccccc", i doubt if it has anything to do with the libraries ...

    This code
    Code:
    conn = env->createConnection(strUser,strPass,strConn);
    probably threw an exception and was catched ...
    Code:
        try
        {
            cout << "Enter password for user YOUR_USER_HERE: ";
            cin >> strPass;
            conn = env->createConnection(strUser,strPass,strConn);
        }
    
        // HERE ... 
        catch (SQLException &sqlExcp)
        {
            cerr << sqlExcp.getMessage() << "Press a key to continue..." << endl;
            cin.ignore();						// Ignore previous ws
            cin.get();
            Environment::terminateEnvironment(env);
            return EXIT_FAILURE;
        }
    but then somehow sqlExcp.getMessage() is throwing another exception ???

  12. #42
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Well, if you've got an exe then the compiling/linking went fine which means the static libs were found and that part of the equation is fine. The only thing I can think of is that you should:
    1. Make sure all the DLLs I've mentioned previously are all present.
    2. Make sure you've got the path environment variable set properly.
    3. Possibly set the TNS_ADMIN environment variable as well.


    It might also be that the createEnvironment call fails (this would mean you're dereferencing a bad pointer [env->] which might be the problem), you could check the value of that call and make sure it isn't null.

    Code:
    Environment * env = 0;
    env = Environment::createEnvironment();
    ...
    
    if(!env)
    {
        // Bad stuff has happened
    }
    else
    {
        // Everything's cool
    }
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  13. #43
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by hk_mp5kpdw View Post
    When you click on Post Reply, there is an area titled "Additional Options" with a "Manage Attachments" button. Click on that button and another pop-up window should appear where you can browse files on your computer and then click on the "Upload" button for each file you wish to attach. When you're done with all the files you want to attach you can close the pop-up window with the "Close this Window" button. When you finally post, those files will be attached to your post.
    Please check the attached files for project properties and libraries ... the file listing image is the location "C:\oraclexe\app\oracle\product\10.2.0\server\OCI\ lib\MSVC\vc8" which is added as additional link/libraries.. Note that i have oracle server installed not client ...
    Last edited by csonx_p; 04-14-2009 at 11:21 AM.

  14. #44
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by hk_mp5kpdw View Post
    Project properties and the dependencies takes care of the .lib issues and linking. Setting up the PATH such that the folder where the .dll files are is included takes care of those (according to the instructions) They are probably in the same location so your first PATH setting should also be pointing to that same folder as in your project's "Additional Library Directories". You should have the following LIB/DLLs present wherever they may be:

    I've also got a couple other files in that directory for whatever reason:



    When you click on Post Reply, there is an area titled "Additional Options" with a "Manage Attachments" button. Click on that button and another pop-up window should appear where you can browse files on your computer and then click on the "Upload" button for each file you wish to attach. When you're done with all the files you want to attach you can close the pop-up window with the "Close this Window" button. When you finally post, those files will be attached to your post.
    where do i get oraociei10.dll file as it seems to be the only file not present according to your list.....

  15. #45
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Go here: Instant Client Downloads

    1. Choose the appropriate link according to your installation.
    2. In the next page you need to click on the "Accept License Agreement" button.
    3. Download the appropriate "Instant Client Package - Basic" that closely matches your Oracle version (you'll probably either want 10.2.0.4 or 10.2.0.3)
    4. Unzip the files to that folder location where you've got all the other DLL/LIB files (you can just overwrite any of your files that are there already).
    5. The ZIP should include the file you're missing (oraociei10.dll).
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What's an import library?
    By chiefmonkey in forum C++ Programming
    Replies: 1
    Last Post: 06-19-2009, 05:00 PM
  2. Property Set Library (PSL) - Announcement
    By vultur_gryphus in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 05-29-2008, 06:04 AM
  3. Makefile for a library
    By sirmoreno in forum Linux Programming
    Replies: 5
    Last Post: 06-04-2006, 04:52 AM
  4. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 07:55 AM
  5. better c string functions
    By samps005 in forum C Programming
    Replies: 8
    Last Post: 11-04-2003, 01:28 PM