Main Page | Class List | File List | Class Members

RMimerDatabase Class Reference

Objects of this class represents a single connection to a Mimer SQL database server. More...

List of all members.


Public Member Functions

IMPORT_C void  BeginTransaction ()
  Begins a database transaction.
IMPORT_C void  Close ()
  Closes the connection to the database.
IMPORT_C void  CommitL ()
  Commits a database transaction.
IMPORT_C TInt  GetLastError ()
  Obtain error information about the last database operation.
IMPORT_C TInt  GetLastError (TDes &aErrorText)
  Obtain error information about the last database operation.
IMPORT_C TBool  IsOpen ()
  Checks the opened/closed state of this handle.
IMPORT_C void  OpenL (const TDesC &aDatabaseName, const TDesC &aUserName, const TDesC &aPassword)
  Opens a connection to a Mimer SQL database server.
IMPORT_C void  OpenL (const TDesC &aConnectionString)
  Opens a connection to a Mimer SQL database server.
IMPORT_C void  RollbackL ()
  Undoes database changes made during a transaction.

Friends

class  RMimerCommand

Detailed Description

Objects of this class represents a single connection to a Mimer SQL database server.

These objects are created by calling the static NewLC() method supplying a connection string. This connection string is documented below.

Once created, applications use the CreateCommandLC() method to create execution environments in which SQL statements may be executed. There may be one and only one transaction active within the connection. Calling one of the transaction manipulating methods BeginTransaction(), CommitL() or RollbackL() therefore affects all execution environments created by this object.

The below code fragment is an example on how this class is used.

 RMimerDatabase database;
 _LIT(database,"the_database");
 _LIT(username,"SYSADM");
 _LIT(password,"SYSADM");
 database.OpenL(database,username,password);
 // All is well. Most commonly, further operations will start by creating one or
 // more command objects.
 _LIT(query,"select CONTACT,PHONENUMBER from CONTACTS where CONTACTNAME like ?");
 RMimerCommand cmd;
 cmd.Create(database,query);
 RMimerResultSet rs = cmd.ExecuteQueryL();
 while (rs.Next()) {
   // Do something exciting with the result set.
 }
 // At the end of the day, we'll close the connection.
 cmd.Close();

Member Function Documentation

IMPORT_C void RMimerDatabase::BeginTransaction  ) 
 

Begins a database transaction.

All operations up until the next CommitL() or RollbackL() call will be executed atomically.

This call is ignored if there is an ongoing transaction.

IMPORT_C void RMimerDatabase::Close  ) 
 

Closes the connection to the database.

Once the connection is closed, the same RMimerDatabase object may be used again to open a new connection.

IMPORT_C void RMimerDatabase::CommitL  ) 
 

Commits a database transaction.

If the commit is successful, any changes are safely written to permanent storage.

If the commit fails, perhaps because of a detected transaction conflict, a TRAP is thrown. See the Mimer SQL Manuals for more information on transaction conflicts.

When a transaction is committed, any open cursors are automatically closed.

IMPORT_C TInt RMimerDatabase::GetLastError  ) 
 

Obtain error information about the last database operation.

The error information is lost once another operation is performed on the database.

Returns:
The Mimer SQL error code. This error code is a negative number.
IMPORT_C TInt RMimerDatabase::GetLastError TDes &  aErrorText  ) 
 

Obtain error information about the last database operation.

The error information is lost once another operation is performed on the database.

Parameters:
aErrorText  A reference to a descriptor to receive a descriptive text about the error.
Returns:
The Mimer SQL error code. This error code is a negative number.
IMPORT_C TBool RMimerDatabase::IsOpen  ) 
 

Checks the opened/closed state of this handle.

Returns:
ETrue if the connection to the database was open, EFalse otherwise.
IMPORT_C void RMimerDatabase::OpenL const TDesC &  aDatabaseName,
const TDesC &  aUserName,
const TDesC &  aPassword
 

Opens a connection to a Mimer SQL database server.

The database to open a connection to is identified using the supplied database name, user name and password.

Parameters:
aDatabaseName  The name of the database to open.
aUserName  The database user name.
aPassword  The password of the given user.
Exceptions:
KErrInUse  if the connection was already open.
KErrCouldNotConnect  if the connection could not be established. Calling GetLastError() may reveal more diagnostics information.
IMPORT_C void RMimerDatabase::OpenL const TDesC &  aConnectionString  ) 
 

Opens a connection to a Mimer SQL database server.

The database to open a connection to is identified using the aConnectionString parameter. This string has the following appearance:

<attribute>=<value>;<attribute>=<value>;...

The following attributes exist:

Attribute Value
NODE Specifies the node or IP number where the server resides. Default: 127.0.0.1
PROTOCOL Protocol to use to connect to the server. Currently only TCP is supported. Default: TCP
SERVICE Additional protocol information. If the protocol was TCP, this specifies the TCP/IP port number. Default: 1360.
DATABASE The name of the database. This entry must be specified.
UID The user name to connect to. his entry must be specified.
PWD The password of the user.

An example of a connection string is:

DATABASE=mimerdb;UID=SYSADM;PWD=SYSADM

Parameters:
aConnectionString  The connection string identifying the database to open.
Exceptions:
KErrInUse  if the connection was already open.
KErrCouldNotConnect  if the connection could not be established. Calling GetLastError() may reveal more diagnostics information.
IMPORT_C void RMimerDatabase::RollbackL  ) 
 

Undoes database changes made during a transaction.

When a transaction is rollbacked, any open cursors are automatically closed.


Submit a comment or suggestion Version 9.2.5b of Mimer C++ API for Symbian OS
Copyright Mimer Information Technology AB, Box 1713, SE-751 47 UPPSALA, Sweden. All Rights Reserved.