Connecting to a Database Using a Connection String
TimesTen applications require a DSN or a connection string be specified to connect to a database.
For modularity and maintainability, it is better to set attributes in a DSN rather than in a connection string within the application, unless a particular connection requires that specific attribute settings override the settings in the DSN or the default settings.
The syntax for a connection string contains connection attribute definitions, where each attribute is separated by a semicolon.
These precedence rules are used to determine the settings of DSN attributes:
-
Attribute settings specified in a connection string have the highest precedence. If an attribute appears more than once in a connection string, the first specification is used.
-
If an attribute is not specified in the connection string, the attribute settings that are specified in the DSN are used.
-
Default attribute settings have the lowest precedence.
The following sections describe how to use a connection string instead of a DSN:
Using a Connection String in TimesTen Scaleout
In TimesTen Scaleout, you can connect to a specific element by specifying in the
connection string the address of the host associated with that element, the database name,
and a database user with at least CREATE SESSION
privileges.
See Using a Connection String to Establish a Client Connection in the Oracle TimesTen In-Memory Database Scaleout User's Guide.
Using a Connection String in TimesTen Classic
You can connect to a TimesTen database without a predefined DSN with any ODBC
application or the ttIsql
utility if the connection string contains the
DataStore
, Driver
and
DatabaseCharacterSet
attributes. Define the connection string as
follows:
-
The name or path name of the ODBC driver using the
Driver
attribute.-
On Windows, the value of the
Driver
attribute should be the name of the TimesTen Client Driver. -
On UNIX systems, the value of the
Driver
attribute should be the pathname of the TimesTen ODBC Driver shared library file (as described in Table 1-1). The file resides in thetimesten_home
/lib
directory.
-
-
The database path and file name prefix using the
DataStore
attribute. -
The character set for the database using the
DatabaseCharacterSet
attribute.
The following example shows how you can connect providing the Driver
, DataStore
and DatabaseCharacterSet
attributes using a connection string in the ttIsql
utility:
Providing the connection attributes on the connect string from a Linux/UNIX client. Note that /disk1/timesten
is the timesten_home
.
% ttIsql Command> connect "Driver=/disk1/timesten/lib/libtten.so; DataStore=/disk1/databases/database1;DatabaseCharacterSet=AL32UTF8";
Providing the connection attributes on the connect string from a Windows client:
C:\ ttIsql
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
Command> connect "Driver=TimesTen Client 22.1;
DataStore=/disk1/databases/database1;DatabaseCharacterSet=AL32UTF8";