Compile and Run the TTClasses Sample Programs


IMPORTANT PRE-REQUISITES

1. Set up the sample database and user accounts

The following build_sampledb script should be run once to set up the sample database and user accounts

Windows:   > cd quickstart/sample_scripts/createdb
> build_sampledb.bat
Unix/Linux:   $ cd quickstart/sample_scripts/createdb
$ ./build_sampledb.sh

2. Set up the environment to compile and run the sample programs

The following script must be run for each of the terminal session:

Windows:   > quickstart/ttquickstartenv.bat
Unix/Linux:   $ . quickstart/ttquickstartenv.sh OR
$ source quickstart/ttquickstartenv.csh

How to compile the sample TTClasses (C++) programs

To compile the sample programs in the sample_code/ttclasses directory, you simply run the makefile supplied in the same directory. Note that the appropriate makefile is made available based on the platform of your TimesTen installation.

To build a specific sample program in the sample_code/ttclasses directory, use the following command:

[Windows] > nmake <program-name>.exe**
[Linux/Unix] $ make <program-name>
where <program-name> is the program you want to compile.

For example, to compile the typetest.cpp program, you do:

[Windows] > nmake typetest.exe**
[Linux/Unix] $ make typetest

Due to C++ name mangling, C++ programs that use C++ libraries need to use compatible C++ compilers (and even C++ compiler versions). To address this C++ compatibility issue, the TimesTen C++ TTClasses library is shipped as source code which enables users to re-compile the TTClasses library with their desired C++ compiler.
The TTClasses library and Quick Start executables are built with Visual Studio 2003 and are shipped by default.

** On Windows, the "nmake" command must be run on a Visual Studio Command Prompt. If you do not use the Visual Studio Command Prompt, you must run the appropriate vcvars*.bat script to set the appropriate environment variables to support command line builds.

 

How to run the sample TTClasses (C++) programs

  basics This sample program is a good starting template for projects that use TTClasses.  It shows how to connect to and disconnect from a TimesTen database and how to prepare, bind, execute, fetch and close SQL statements.  Examples of TTClasses exception handling and timing SQL operations for both serializable and committed read transactions are shown.

  Examples:

  (Run as appuser: DSN=sampledb_1122;UID=appuser)
  basics

  (Run as instance administrator)
  basics sampledb_1122

  (Run as user adm in Client/Server mode)
  basicsCS -connstr "DSN=sampledbCS_1122;uid=adm"

  For full syntax of the program, try "basics -help".

  bulkcp This sample program uses dynamic SQL to run a SQL query and writes the output to the console or a file.  The user enters the SQL query on the command line.  The user can optionally specify the characters to display for NULL values and column separator.

  Examples:

  (Display user query to STDOUT with default separators)
  bulkcp -query "SELECT * from emp"

  (Display user query to a file with default separators on Linux/Unix)
  bulkcp -query "SELECT * from dept" -output /tmp/myQuery.txt

  (Display user query to a file with a non default separator on Windows)
  bulkcp -sep " " -query "SELECT * from dept" -output c:\tmp\myQuery.txt

  For full syntax of the program, try "bulkcp -help".

 

  bulktest This sample code executes a series of insert, update and delete operations first in 'non-bulk' and then in 'bulk' mode with variable batch sizes. When the "batchsize" is set to 256 (the optimal value), significant performance benefits can be achieved for insert operations and modest improvements for update and delete operations.

Examples:

  (Without any parameters, the program runs with the default settings: DSN=sampledb_1122;UID=appuser; batch size= 256)
  bulktest

  (Run the program with batch size = 512, use default connect string (dsn=sampledb_1122 and uid=appuser)
  bulktest -batchsize 512

  (Run the program against a different dsn and user id of your choice)
  bulktest -connstr "DSN=sampledb_1122;uid=adm"

  For full syntax of the program, try "bulktest -h".

 

  catalog This sample program prints out the database schema information including all tables, views, and indexes.

Examples:

  (Without any parameters, the program runs with the default settings: DSN=sampledb_1122;UID=appuser)
  catalog

  (Run the program against a different dsn and user id of your choice)
  catalog -connstr "DSN=sampledb_1122;uid=adm"

  For full syntax of the program, try "catalog -h".

 

  plsqlTTCLASSES This sample program uses TTClasses to access common PL/SQL packages (emp_pkg and sample_pkg) in four different ways:

- Calls a stored procedure with IN and OUT parameters
- Calls a stored function with IN and OUT parameters
- Calls an anonymous block and passes host variables into and out of the block
- Calls a store procedure to open a ref cursor and uses TTClasses to process the result-set of the ref cursor

The EMP table and the emp_pkg and sample_pkg PL/SQL packages need to exist for this program to work.

Example usage:

  (run the program using the default DSN and default user , it will prompt for the password)
  plsqlTTCLASSES

  (run the program specifying the DSN and username, it will prompt for the password)
  plsqlTTCLASSES -connstr "DSN=sampledb_1122;UID=appuser"

  (run the program specifying the DSN, username and password)
  plsqlTTCLASSES -connstr "DSN=sampledb_1122;UID=appuser;PWD=mypassword"

For full syntax of the program, try "plsqlTTCLASSES -h".

 

  pooltest This sample program demonstrates multi-threaded connection pool usage and error handling. This program shows how to use the TTConnectionPool class in TTClasses in a multi-threaded application. The user can specify the number of threads to use for the insert operations and the number of connections to keep in the connection pool.

Examples:

  (Without any parameters, the program runs use the default of 1 connection, 2 insert threads, 2 fetch threads, and DSN=sampledb_1122;UID=appuser)
  pooltest

  (Run the program specifying 2 connections, 4 insert threads)
  pooltest -insert 4 -conn 2

  (Run the program against a different dsn and user id of your choice)
  pooltest -connstr "DSN=sampledb_1122;uid=adm"

  For full syntax of the program, try "pooltest -h".

 

  ttSizeAll This sample program demonstrates calling TimesTen utility ttSize for multiple tables. Only the tables which the user has read permissions on will be shown.

Examples:

  (Without any parameters, the program uses DSN=sampledb_1122;UID=appuser)
  ttSizeAll

  (Show both user and system tables in the output)
  ttSizeAll -listsys

  (Run the program against a different dsn and user id of your choice)
  ttSizeAll -connstr "dsn=sampledb_1122;uid=xlauser"

  For full syntax of the program, try "ttSizeAll -h".

 

  typetest This sample program demonstrates the use of different datatypes supported by Oracle TimesTen by creating a table, typetest, which contains columns of all supported datatypes. The program then inserts data into the table and queries the data from the table.

Examples:

  (Without any parameters, the program runs with the default settings: DSN=sampledb_1122;UID=appuser )
  typetest

  (Run the program against a different dsn and user id of your choice)
  typetest -connstr "dsn=sampledb_1122;uid=appuser"

  For full syntax of the program, try "typetest -h".

  ttXlaAdmin This particular TTClasses sample program is available in the quickstart/sample_code/ttclasses/xla directory.

This program shows how to list or remove XLA bookmarks in the database. This program requires a user with ADMIN privilege to run because only the administrator is allowed to see all bookmarks in the system. An user with the XLA privilege is allowed to list or remove his/her own bookmark.

Unwanted bookmarks that are preventing transaction log files from being purged can create operational issues on the system and should be removed.

The "list" option is the default option for running the program without any input. For each XLA bookmark found in the system, the program lists the bookmark name, its LSN and whether the bookmark is holding transaction logs.

The "remove" option allows the user to delete the XLA bookmark via its bookmark name.  The "removeall" option allows all of the bookmarks to be deleted.  Bookmarks can only be deleted when not in use.

Examples:

  (Without any parameters, the program executes the "list" command and connects to DSN=sampledb_1122;UID=adm)
  ttXlaAdmin

   (Remove all of the XLA bookmark for any user in the DB. The user needs to have ADMIN privilege to do this.)
  ttXlaAdmin -removeall

  (Remove a specific bookmark. The user needs to have ADMIN privilege to do this.)
  ttXlaAdmin -remove <bookmark>

  For full syntax of the program, try "ttxlaAdmin -h".

 

  xlasubscriber1 This particular TTClasses sample program is available in the quickstart/sample_code/ttclasses/xla directory.

This program shows how to use the Transaction Log API (XLA) facility to subscribe to change notifications for a table, chosen by the user at run time.

This program shows how to create persistent XLA bookmark and monitor and process changes on the specified table. The program displays the change records processed and the operations that were performed on the table (insert, update, or delete) to cause the change.

To create workload on the table being tracked, use a ttIsql session or a TimesTen user application to inject changes to the the table being tracked. This program requires a user with XLA privilege to run.

Examples:

  (Without any parameters, the program connects to DSN=sampledb_1122;UID=xlauser, and prompt for the table to track)
  xlasubscriber1

  (Run the program against a different dsn and user id of your choice; the user needs to have XLA privilege)
  xlasubscriber1 -connstr "dsn=<mydsn name>;uid=<myusername>"

  For full syntax of the program, try "xlaSubscriber1 -h".

 

  xlasubscriber2 This particular TTClasses sample program is available in the quickstart/sample_code/ttclasses/xla directory.

This program shows how to subscribe to XLA events on multiple tables of interest (in this case three). This program monitors changes to three tables: MYTABLE, ICF and ABC.

The column names and their values are shown for every row affected by the transaction's inserts, updates and deletes.  To create the transactional workload, a ttIsql session or a TimesTen user application can perform the transactions to the MYTABLE, ICF and/or ABC tables. 

This program is an example of an XLA subscriber which only has the permission to see the changes to the table of interest, but not to access the table of interest itself. The program requires a user with XLA privilege to run.

Examples:

  (Without any parameters, the program connects to DSN=sampledb_1122;UID=xlauser)
  xlasubscriber2

  (Run the program against a different dsn and user id of your choice; the user needs to have XLA privilege)
  xlasubscriber2 -connstr "dsn=<mydsn name>;uid=<myusername>"

  For full syntax of the program, try "xlasubscriber2 -h".

For more information on TTClasses, refer to the Oracle TimesTen In-Memory Database TTClasses Guide.