Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2008
    Posts
    5

    Unanswered: ADO Catastrophic error when opening connection as Windows service on Oracle 10

    Dear all,
    I am maintaining a Windows application that can run both from command line and as a Windows service. The application connects to an Oracle DB upon startup.

    When launching the application on an Oracle 9.2 or 8.1.7 client, everything goes well, both from command line and as a Windows service. When launching it from command line on Oracle 10, everything goes well.

    When launching it as a Windows service from a machine with Oracle 10 installed, I receive the following error when trying to open the connection:

    Error -2147418113: Catastrophic failure

    Executing the service as myself, instead of Local System, or allowing the service to interact with desktop, makes no difference.

    This code snippet illustrates the problem:

    Code:
    ofstream out("path-to-my-log-file.txt", ios_base::app);
    const char *s = "..."; // a valid connection string
    
    try
    {
    	if(FAILED(::CoInitialize(NULL)))
    	    return;
    
    	_ConnectionPtr _connection;
    	_connection.CreateInstance(__uuidof(Connection));
    
    	out << "Opening " << s << endl;
    	_connection->Open (s, "", "", adConnectUnspecified);
    
    	// Windows service on Oracle 10 fails on Open()
    
    	out << "Closing connection" << endl;
    	_connection->Close();
    
    	out << "Done" << endl;
    }
    catch (_com_error &e)
    {
    	out << "Error " << e.Error() << ": " << e.ErrorMessage() << endl;
    }
    Some more details:
    • I am running Windows XP Professional, Service Pack 2
    • I have Oracle 10g XE Server (10.2.0) installed on my machine, but I could reproduce the problem on a machine with the client components only


    The attached .zip file contains the sources for a more complete example.

    Thanks in advance for your help!
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Whoa! I'm sorry for wasting your time (as I'm unable to help you), but - seeing a title about the "catastrophic error", my first thought was that this man is certainly exaggerating. But no, it is a true catastrophe! Amazing!

  3. #3
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  4. #4
    Join Date
    Jan 2008
    Posts
    5
    Quote Originally Posted by beilstwh
    Thanks, but the KB article is about a different problem ("operation following a rollback or a commit transaction on a recordset opened as a serverside cursor").

    My problem is that I don't even manage to open the connection.

  5. #5
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >When launching the application on an Oracle 9.2 or 8.1.7 client, everything goes well, both from command line and as a Windows service. When launching it from command line on Oracle 10, everything goes well.

    >When launching it as a Windows service from a machine with Oracle 10 installed, I receive the following error when trying to open the connection:

    >Error -2147418113: Catastrophic failure
    So explain again why this is an Oracle problem & NOT a Windoze failure;
    because it looks to me like a pure Windoze problem.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  6. #6
    Join Date
    Jan 2008
    Posts
    5
    Quote Originally Posted by anacedent
    So explain again why this is an Oracle problem & NOT a Windoze failure;
    because it looks to me like a pure Windoze problem.
    Because, with the same OS version, my test program works on Oracle 9 client and it fails on Oracle 10 client.

    Because if I create a Microsoft Access file, say "C:\test.mdb", and I run my test program with this connect string "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.mdb", it works both from command line and as a Windows service.

    Either of these points makes me think this is an Oracle problem (at least in part ; mind you, I'm not saying that Windows is blameless...)


    Meanwhile, some more failed attempts to solve the issue: using specific versions of ADO (msado20.tlb through msado27.tlb) instead of msado15.dll makes absolutely no difference.

  7. #7
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Read the article. There solution was to UPGRADE the ODBC client, the version for Oracle 9 does not support all the calls and data types from Oracle 10.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  8. #8
    Join Date
    Jan 2008
    Posts
    5
    Quote Originally Posted by beilstwh
    Read the article. There solution was to UPGRADE the ODBC client, the version for Oracle 9 does not support all the calls and data types from Oracle 10.
    Bill, thanks for the suggestion.

    I did read the article (http://support.microsoft.com/default.aspx/kb/187942) which does not mention upgrading ODBC - their solution was to "use adUseClient". Possibly you meant a different article?

    Anyway, I downloaded the most recent versions of MDAC from the Microsoft site. Installing "MDAC 2.7 Service Pack 1 Refresh" did not have any effect, while MDAC 2.8 would not install ("MDAC 2.8 RTM is incompatible with this version of Windows. All of its features are currently part of Windows").

    By the way, a preliminary test using the ODBC API instead of ADO seems to be working fine also when running as a service and using Oracle 10. Unfortunately, porting the full application to ODBC would not be as easy (nor as safe) as porting the test program.
    Last edited by paolog; 01-17-08 at 13:05.

  9. #9
    Join Date
    Jan 2008
    Posts
    5

    ADO Catastrophic error when opening connection as Windows service, Oracle 10 [SOLVED]

    Finally the problem is solved. It seems that, when you use it from a Windows service, the Oracle 10 driver does not initialize correctly the first time, regardless of the API (ADO or ODBC), but if you ignore the error and try again, everything works fine.

    So I solved the problem like this:

    Code:
    // The following is a workaround for a bug in the Oracle 10 client,
    // only affecting the application when it runs as a system service.
    // Dut to this bug, the first attempt to open a connection fails
    // ("catastrophic failure") but subsequent attempts (on separate
    // Connection objects) work correctly.
    try {
    	_ConnectionPtr workaround;
    	TESTHR(workaround.CreateInstance(__uuidof(Connection)));
    	workaround->Open(myConnectString, "", "", adConnectUnspecified);
    	workaround->Close();
    }
    catch (...)
    {
    	;
    }
    
    TESTHR(myConnection.CreateInstance(__uuidof(Connection)));
    myConnection->Open(myConnectString, "", "", adConnectUnspecified);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •