Managing TimesTen Connections

This section covers how to connect to a database.

Setting Connection Attributes for the Database

This section refers to information about setting up a TimesTen database, including initial connection attribute settings.

For TimesTen Classic, Oracle TimesTen In-Memory Database Operations Guide contains information about creating a DSN (data source name) for a database. A DSN is a logical name that identifies a TimesTen database and the set of connection attributes used for connecting to the database. The type of DSN you create depends on whether your application connects directly to the database or connects by a client. If you intend to connect directly to the database, refer to Managing TimesTen Databases. If you intend to create a client connection to the database, refer to Working with the TimesTen Client and Server.

For TimesTen Scaleout, refer to Oracle TimesTen In-Memory Database Scaleout User's Guide for information about creating a database, setting connection attributes, and connecting to a database, using either a direct connection or a client/server connection. See Creating a Database and Connecting to a Database.

Note:

A TimesTen connection cannot be inherited from a parent process. If a process opens a database connection before creating (forking) a child process, the child must not use the connection.

Connecting and Disconnecting

Based on the XYZConnection class, you can connect to and disconnect from TimesTen.

See Using TTCmd, TTConnection, and TTConnectionPool.

For example:

  ...

  XYZConnection conn;
  char connStr[256];
  char user[30];
  char pwd[30];
 
  ...
 
  try {
    conn.Connect(connStr, user, pwd);
  }
  catch (TTWarning st) {
    cerr << "Warning connecting to TimesTen: " << st << endl;
  }
  catch (TTError st) {
    cerr << "Error connecting to TimesTen " << st << endl;
    exit(1);
  }

// ... Work with the database connection...

  try {
    conn.Disconnect();
  }
  catch (TTStatus st) {
    cerr << "Error disconnecting from TimesTen: " << st << endl;
    exit(1);
  }

Connection Methods

There are method signatures for the TTConnection, TTConnectionPool, and TTXlaPersistConnection classes.

virtual void 
TTConnection::Connect(const char* connStr)
 
virtual void
TTConnection::Connect(const char* connStr, const char* username, 
                      const char* password)
 
virtual void
TTConnection::Connect(const char* connStr, 
                      DRIVER_COMPLETION_ENUM driverCompletion)

void 
TTConnectionPool::ConnectAll(const char* connStr)

void
TTConnectionPool::ConnectAll(const char* connStr, const char* username, 
                             const char* password)
 
virtual void
TTXlaPersistConnection::Connect(const char* connStr, const char* username, 
                                const char* password, const char* bookmarkStr, 
                                bool createBookmarkFlag)
 
virtual void
TTXlaPersistConnection::Connect(const char* connStr, 
                                DRIVER_COMPLETION_ENUM driverCompletion, 
                                const char * bookmarkStr, bool createBookmarkFlag)
 
virtual void
TTXlaPersistConnection::Connect(const char* connStr, const char* username, 
                                const char* password, const char* bookmarkStr)

virtual void
TTXlaPersistConnection::Connect(const char* connStr, 
                                DRIVER_COMPLETION_ENUM driverCompletion, 
                                const char * bookmarkStr)

Note:

  • The connection string (connStr value) can specify the user name and password, such as "DSN=testdb;uid=brian;pwd=password". Be aware that for signatures that take connection string, user name, and password arguments, the user name and password arguments take precedence over any user name or password specified in the connection string.

  • See TTConnection Reference for information about DRIVER_COMPLETION_ENUM values.