single_task

Directory

eXtremeDB_rt/samples/single_task

Description

Demonstrates opening and connecting to a database from a single task (process).

Used API

sample_open_database(), mco_db_connect(), mco_db_disconnect(), sample_close_database()

Code snippet

 
    rc = sample_open_database( db_name, simpledb_get_dictionary(), DATABASE_SIZE, 
  CACHE_SIZE, 
                               MEMORY_PAGE_SIZE, PSTORAGE_PAGE_SIZE, 1, &dbmem );                            
    sample_rc_check("\tOpen database", rc );
  
    if ( MCO_S_OK == rc ) {
  
      /* The database was opened successfully */
      /* Connect to it by name */   
      mco_db_h connection; /* Connection handle */
      rc = mco_db_connect( db_name, &connection );
  
      if ( MCO_S_OK == rc ) {
        /* The database is open and a connection successfully established */
        sample_rc_check("\tConnect database", rc );
  
        /* Perform desired database operations ... */
  
        /* Do not forget to disconnect it when done */
        rc = mco_db_disconnect( connection );
        sample_rc_check("\tDisconnect database", rc );
      }
  
      /* Close the database */
      sample_close_database( db_name, &dbmem );

What to expect as an output

 
        Open database : Successful
	Connect database : Successful
	Disconnect database : Successful