Page 1 of 1

How to know the database is online or not @_@

Posted: Thu 15 Jan 2009 08:57
by tangaslie
Dear all,

I am using the handheld to insert the data to the Oracle database frequently. We cannot afford any data losing. Therefore, we have an Online Mode and Offline Mode in programming. If the database is online we will insert the data immediately. Otherwise, we will write it on a text file. Recently, we do not know the database is online or not so that we don’t know how to do it. What can I do beside the TRY CATCH statement?

Thanks,
Aslie

Posted: Thu 15 Jan 2009 13:24
by Shalex
The state of the OracleConnection object can be checked by the help of its State property. But the database can be unavailable even if the OracleConnection.State property is ConnectionState.Open. Therefore execute some query to ensure the connection is valid before using the OracleConnection object.
We recommend to use the try...catch statement:

Code: Select all

      try {
        if (connection.State != ConnectionState.Open)
          connection.Open();
        OracleCommand command = new OracleCommand("begin null; end;", connection);
        command.ExecuteNonQuery();
        // code that works with database
      }
      catch { 
        
        //code that works with file
      }

Posted: Fri 16 Jan 2009 02:42
by tangaslie
I found that the performance is very fast at the Connection.Open even it is not connecting to the database. However, when the program run this statement:

Dim myReader As OracleDataReader = myCommand.ExecuteReader()

it takes about 15-20 seconds before go to CATCH statement.

Thanks

Posted: Fri 16 Jan 2009 13:28
by Shalex
We don't know the faster way. This delay is caused by OCI.

Posted: Mon 19 Jan 2009 09:15
by tangaslie
May I know is there are any solution to change the OCI timeout property?

Thanks

Posted: Mon 19 Jan 2009 13:42
by Shalex
The OCI timeout property can not be changed.

Posted: Tue 20 Jan 2009 01:33
by tangaslie
Actually, we tried to use the Direct mode to connect the database. The system got an error:

"Unknown connection string parameter Direct."

My Corelab.Oracle version is 4.75.42.1 and runtime version is v2.0.50727. If the version 5.x can solve this problem, is there are any free upgrade?

Thanks

Posted: Tue 20 Jan 2009 08:50
by Shalex
Probably you are using Mobile Edition of dotConnect for Oracle. Mobile Edition doesn't use Oracle client software, it can work only in Direct mode (the Direct property is always set to true). That's why it is not allowed to set/change this property. The Timeout property is not available in Mobile Edition.
Please refer to http://www.devart.com/forums/viewtopic.php?p=42076 , where this issue is discussed.