Home | Previous Page | Next Page   Database Access > Handling Connections > Initializing a Client Connection >

Using Database Parameters

To indicate which database it needs to connect to, the client LIBMI application uses database parameters. The DataBlade API provides a database-information descriptor, MI_DATABASE_INFO, to access database parameters. This data type structure identifies the database for a particular session.

Unlike most DataBlade API structures, the database-information descriptor is not an opaque C data structure. To access database information, you must allocate a database-information descriptor and directly access its fields. Table 47 shows the fields in the database-information descriptor.

Table 47. Fields in the Database-Information Descriptor
Field Data Type Description
database_name char * The name of the database
user_name char * The user account name, as defined by the operating system
password char * The account password, as defined by the operating system

The milib.h header file defines the MI_DATABASE_INFO structure.

With the database-information descriptor, you can use the following DataBlade API functions to perform the database-parameter tasks.

Database-Parameter Task DataBlade API Function
Access the default database parameters to determine the database and user for the connection mi_set_default_database_info( ),
mi_get_default_database_info( )
Obtain current database parameters for an open connection mi_get_database_info( )

Establishing Default Database Parameters

The default database parameters identify the database and user for the connection. Before you establish a connection, you can determine which of the following database parameters to use:

System-Default Database Parameters

The database server obtains values for the system-default database parameters from the execution environment of the client LIBMI application. When you use system-default database parameters, you enable your application to be portable across client/server environments. However, you must ensure that the client/server environment is correctly initialized to provide the system-default values.

Table 48 shows the system-default database parameters that the database server uses to open a database.

Table 48. System-Default Database Parameters
System-Default Database Parameter System-Default Value
Database name None
User-account name Account name of user that invoked the client LIBMI application
Account password Account password of user that invoked the client LIBMI application

The system-default database parameters provide database information for all connections made within a client LIBMI application unless you explicitly override them within the application.

User-Defined Database Parameters

The database server obtains values for the database parameters from the database-information descriptor. The database server initializes the database-information descriptor with the system-default database parameters in Table 48. You can initialize your own database-information descriptor to override the default database parameters. When you override system-default database parameters, you enable your application to have database information that is independent of the client/server environment in which it runs.

To override the system-default database parameters
  1. Allocate a database-information descriptor.
  2. Fill the fields of the database-information descriptor with the default database parameters you need.

    If you do not set a particular field, the database server uses the system-default value in Table 48 for the associated database parameter.

  3. Pass a pointer to this database-information descriptor to the mi_set_default_database_info( ) function.

The user-defined database parameters provide database information for all connections made within a client LIBMI application after these functions execute (unless the functions are called again to set new default values).

You can obtain existing default database parameters with the mi_get_default_database_info( ) function. This function populates a user-defined database-information descriptor with the current default database parameters.

Server Only

In a C UDR, mi_get_default_database_info( ) obtains the same information as mi_get_database_info( ). The mi_set_default_database_info( ) function is ignored.

End of Server Only

Obtaining Current Database Parameters

To obtain database parameters associated with an open connection, use the mi_get_database_info( ) function. This function populates a user-defined database-information descriptor with values from the specified open connection.

Server Only

The mi_get_database_info( ) function is valid with a C UDR.

End of Server Only
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]