DSN Examples for TimesTen Classic

This section provides additional examples of how to set up a TimesTen Classic database:

Creating Multiple DSNs to a Single TimesTen Classic Database

You can create two or more DSNs that refer to the same TimesTen Classic database but have different connection attributes.

This example creates two DSNs, AdminDSN and GlobalDSN. The DSNs are identical except for their connection character sets. Applications that use the AL32UTF8 character set can connect to the TTDS database by using AdminDSN. Applications that use multibyte characters can connect to the TTDS database by using GlobalDSN.

The text in square brackets is the data source name.

AdminDSN is created with the AL32UTF8 database character set and AL32UTF8 as the connection character set. GlobalDSN is created with the AL32UTF8 database character and AL32UTF8 as the connection character set. Note that /disk1/timesten is the timesten_home.

[AdminDSN]
Driver=/disk1/timesten/lib/libtten.so
Datastore=/disk1/databases/TTDS
DatabaseCharacterSet=AL32UTF8
ConnectionCharacterSet=AL32UTF8
CacheAdminWallet=1

[GlobalDSN]
Driver=/disk1/timesten/lib/libtten.so
DataStore=/disk1/databases/TTDS
DatabaseCharacterSet=AL32UTF8
ConnectionCharacterSet=AL32UTF8
CacheAdminWallet=1

Specifying PL/SQL Connection Attributes in a DSN

For TimesTen Classic, PL/SQL connection attributes exist both as first and general connection attributes.

  • PLSQL_MEMORY_ADDRESS - A first connection attribute that specifies the virtual address, as a hexadecimal value, at which the PL/SQL shared memory segment is loaded into each process that uses the TimesTen direct drivers. This memory address must be identical in all connections to your database and in all processes that connect to your database.

  • PLSQL_MEMORY_SIZE - A first connection attribute that determines the size, in megabytes, of the PL/SQL shared memory segment.

  • PLSCOPE_SETTINGS - A general connection attribute that controls whether the PL/SQL compiler generates cross-reference information.

  • PLSQL_OPTIMIZE_LEVEL - A general connection attribute that sets the optimization level that is used to compile PL/SQL library units.

This example creates the PLdsn DSN and sets the PL/SQL shared memory segment size to 32 MB.

[PLdsn]
Datastore=/disk1/databases/PLdsn
PermSize=128
DatabaseCharacterSet=AL32UTF8
ConnectionCharacterSet=AL32UTF8
PLSQL_MEMORY_SIZE=32
CacheAdminWallet=1

For more examples and a complete list of PL/SQL connection attributes see PL/SQL Connection Attributes in Oracle TimesTen In-Memory Database PL/SQL Developer's Guide.

Setting Up a Default DSN in TimesTen Classic

You can add an optional default data source definition in TimesTen Classic.

At connect time, if an application specifies a DSN that is not in the odbc.ini file or if the application does not specify a DSN, the default DSN is used to configure the connection to the TimesTen Classic database.

The default data source must be named default when defined. The default DSN can be defined with the same attributes as any other data source, which are described in DSN Specification.

When connecting, TimesTen Classic uses the default DSN in any of the following scenarios:

  • When you specify the DSN=default keyword-value pair in the connection string.

  • When you specify an undefined value for the DSN connection attribute in the connection string.

  • When you do not specify any value for the DSN connection attribute in the connection string.

However, in general, it is best to connect with a specific data source.

When using a default DSN, provide default as the DSN name when performing TimesTen utility operations that require a DSN name, such as destroying the database with the ttDestroy utility.

The following example shows the user invoking ttIsql to connect using an undefined DSN. Since there is no definition for doesNotExist in the odbc.ini file, TimesTen Classic uses the default DSN to create the database and initiate a connection to it. It also demonstrates the user invoking both the ttStatus and ttDestroy utilities with default specified as the DSN. In addition, it shows the error thrown if the user provides doesNotExist as the DSN, instead of default.

% ttIsql doesNotExist;
 
Copyright (c) 1996, 2024 Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
 
connect "DSN=doesNotExist";
Connection successful:
Command> exit
Disconnecting...
Done.
% ttStatus default
TimesTen status report as of Mon Oct 22 12:27:52 2021
 
Daemon pid 13623 port 16138 instance myhost
TimesTen Server pid 13632 started on port 16140
------------------------------------------------------------------------
Data store /timesten/install/sample_db/default
There are no connections to the data store
Replication policy  : Manual
Cache Agent policy  : Manual
PL/SQL enabled.
------------------------------------------------------------------------
Accessible by group xyz
End of report
% ttDestroy doesNotExist;
Failed to destroy data store: Specified DSN is not found in user and system
odbc.ini files (or registry)
% ttDestroy default; 

The following example shows how to configure connection attributes for a default DSN. While not necessary, you can configure connection attributes for a default DSN as you would configure any other DSN. Notice that it is not specified in the ODBC Data Sources section. Note that /disk1/timesten is the timesten_home.

[ODBC Data Sources]
database1=TimesTen 22.1 Driver
 
[default]
Driver=/disk1/timesten/lib/libtten.so
DataStore=/disk1/timesten/sample_db/DemoDataStore/default
PermSize=128
TempSize=64
DatabaseCharacterSet=AL32UTF8
CacheAdminWallet=1

[database1]
Driver=/disk1/timesten/lib/libtten.so
DataStore=/disk1/timesten/sample_db/DemoDataStore/database1
PermSize=128
TempSize=64
DatabaseCharacterSet=AL32UTF8
CacheAdminWallet=1