InformixAdaptor

Inherits From:
EOAdaptor : NSObject

Declared in: InformixEOAdaptor/InformixAdaptor.h

Class Description

An InformixAdaptor represents a single connection to an Informix database server, and is responsible for keeping login and model information, performing Informix-specific formatting of SQL expressions, and reporting errors.

The InformixAdaptor class has these restrictions: You can't have nested transactions, and the adaptor doesn't support full outer joins.

The Connection Dictionary

The connection dictionary contains items needed to connect to an Informix server, such as the database name (it's common to omit the user name and password from the connection dictionary, and prompt users to enter those values in a login panel). The keys of this dictionary identify the information the server expects, and the values of those keys are the values that the adaptor uses when trying to connect to the server. For Informix databases the required keys are as follows:

dbName

userName

password

Locking

All adaptors use the database server's native locking facilities to lock rows on the server. In the Informix adaptor locking is determined by the isolation level, which is implemented in InformixChannel. Locking occurs when:

Data Type Mapping

Every adaptor provides a mapping between each server data type and the Objective-C type to which a database value will be coerced when it's fetched from the database. The following table lists the mapping used by InformixAdaptor.

Informix Data Type

Objective-C Data Type

VARCHAR NSString
NVARCHAR NSString
DECIMAL NSDecimalNumber
MONEY NSDecimalNumber
BYTE NSData
TEXT NSString
DATE NSCalendarDate
INTEGER NSNumber
SMALLINT NSNumber
NCHAR NSString
CHAR NSString
SERIAL NSNumber
FLOAT NSNumber
SMALLFLOAT NSNumber
DATETIME YEAR TO SECOND NSCalendarDate
INTERVAL NSString

The type mapping methods-externalTypesWithModel: , internalTypeForExternalType:model: , and isValidQualifierType:model: -allow for an adaptor to supplement its set of type mappings with additional mappings for user-defined database types. InformixAdaptor does not make use of the model argument if one is provided.

Method Types

Mapping external types to internal types
+ externalTypesWithModel:
+ internalTypeForExternalType:model:
Working with channels and contexts
- adaptorChannelClass
- adaptorContextClass
Testing the connection dictionary
- assertConnectionDictionaryIsValid
Getting information from the connection dictionary
- informixConnectionString
- informixDefaultForKey:
- connectionKeys
Getting the default expression class
- defaultExpressionClass
Verifying a qualifier type
- isValidQualifierType:model:
Error handling
- raiseInformixError:

Class Methods

externalTypesWithModel:

+ (NSArray *)externalTypesWithModel:(EOModel *)model

Overrides the EOAdaptor method externalTypesWithModel: to return the Informix database types.

See also: + internalTypeForExternalType:model:

internalTypeForExternalType:model:

+ (NSString *)internalTypeForExternalType:(NSString *)externalType model:(EOModel *)model

Overrides the EOAdaptor method internalTypeForExternalType: to return the name of the Objective-C class used to represent values stored in the database as externalType.

See also: + externalTypesWithModel:

Instance Methods

adaptorChannelClass

- (Class)adaptorChannelClass

Returns the InformixChannel class.

adaptorContextClass

- (Class)adaptorContextClass

Returns the InformixContext class.

assertConnectionDictionaryIsValid

- (void)assertConnectionDictionaryIsValid

Overrides the EOAdaptor method assertConnectionDictionaryIsValid to verify that the receiver can connect to the database with its connection dictionary. Briefly forms a connection to the server to validate the connection dictionary and then closes the connection (in other words, this method doesn't open a connecton to the database-that happens when the first adaptor channel is sent an openChannel message). The adaptor uses this method in conjunction with displaying a server login panel. Raises an exception if an error occurs.

connectionKeys

- (NSArray *)connectionKeys

Returns an NSArray containing the keys in the receiver's connection dictionary. You can use this method to prompt the user to supply values for the connection dictionary.

defaultExpressionClass

- (Class)defaultExpressionClass

Returns the InformixSQLExpression class.

informixConnectionString

- (NSString *)informixConnectionString

Returns the user name, password, and database name as a string suitable to be supplied as an argument to db_connect().

informixDefaultForKey:

- (NSString *)informixDefaultForKey:(NSString *)key

Returns the user default setting for key. To get this information it first checks the user defaults, and then the adaptor's internal defaults dictionary.

isValidQualifierType:model:

- (BOOL)isValidQualifierType:(NSString *)typeName model:(EOModel *)model

Overrides the EOAdaptor method isValidQualifierType:model: to return YES if an attribute of type typeName can be used in a qualifier (a SQL WHERE clause) sent to the database server, or NO otherwise. typeName is the name of a type as required by the database server, such as an Informix "VARCHAR".

raiseInformixError:

- (void)raiseInformixError:(NSString *)sqlString

Examines Informix structures for error flags and raises an exception if one is found. Extracts the error information in the connection structure and use it to build and raise an exception.

Copyright © 1997, Apple Computer, Inc. All rights reserved.