Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

Session Properties

The default session properties are suitable for most c-treeDB applications. Advanced developers may need to tune c-treeDB to meet application requirements. Use CTSession::SetSessionParams() to set the following properties:

Table 3-1: Default Session Parameters

Property

Explanation

Default

BUFS

Index file buffers

10

FILS

File structure blocks

32

SECT

Node sectors

32

DBUFS

Data file buffers

10

USERPROF

User profile mask

513

The default USERPROF value of 513 tells single-user, transaction-control applications, to remove the auxiliary log files S*.FCS and L*.FCS upon successful termination of the application, and also removes the automatic key transformation.

The table below present all possible values for the USERPROF parameter. See InitISAMXtd for detailed descriptions.

User Profile Values

Keyword

Value

Explanation

USERPRF_NTKEY

1

Do not perform auto tfrmkey

USERPRF_SAVENV

2

Savenv mode for transactions

USERPRF_NDATA

32

Do not perform auto data - UNIFRMAT conversion

USERPRF_LOCLIB

64

Use a local library: not server

USERPRF_PTHTMP

128

Add tmpname to input path, otherwise use system tmpname

USERPRF_CLRCHK

512

Clear transaction logs

Example


// set a different user profile before logging on to a session

CTSession ASession;

try

{

// set the new profile

ASession.SetSessionParam(USERPROF, (USERPRF_NTKEY | USERPROF_CLRCHK));


// logon to a session

ASession.Logon("FAIRCOMS", "ADMIN", "ADMIN");

}

catch (CTException &err)

{

printf("Session logon failed with error %d\n", err.GetErrorCode());

}


In This Section

Server and User Name Properties

Active Property

Path Property

Previous Topic

Next Topic

Server and User Name Properties

Once a session is active, the user may retrieve the server name for the session with CTSession::GetServerName(). Retrieve the user name by calling the CTSession::GetUserLogonName() method. Please refer to the example in "Active property".

Previous Topic

Next Topic

Active Property

A session is active if the user has logged on to a valid session dictionary using CTSession::Logon(). To render a session inactive, log off using CTSession::Logout(). To verify the status of the session, use CTSession::IsActive().

Example


//if session is active, retrieve the server name and user logon name

if (ASession.IsActive())

{

printf("Server name: %s\n", ASession.GetServerName());

printf("User name : %s\n", ASession.GetUserLogonName());

}


Previous Topic

Next Topic

Path Property

The default path for client/server applications is the server directory, while the default path for non-server applications is the application directory. If, for any reason, there is the need to modify the location of the session dictionary, the CTSession::SetPath() may be used, before creating and/or logging on to the session. CTSession::GetPath() may be used to retrieve the path for an active session.

Using this property, it is even possible to have multiple session dictionaries, in separate directories. This is not required, since the concepts of restricting access to different users to diverse tables or databases may be implemented inside a unique session dictionary.

The example below shows how to use the CTSession::SetPath() function to create a session dictionary file in a user specified directory, instead of the default directory:

Example


CTSession ASession;

try

{

ASession.SetPath("\new\session");

ASession.Create("FAIRCOMS", "ADMIN", "ADMIN");

}

catch (CTException &err)

{

printf("Create session failed with error %d\n", err.GetErrorCode());

}


TOCIndex