Configuring Data Sources

After you install the driver, you need to configure a data source or use a connection string to connect to the database. If you want to use a data source, but need to change some of its values, you can either modify it or override its values through a connection string. See "Quick Start Connect" for an explanation of different types of data sources.

If you choose to use a connection string, you must use specific connection string attributes. See "Connecting to a Data Source Using a Connection String" and Table 15-4 for a complete description of driver connection string attributes and their values.

UNIX

On UNIX and Linux, you must set up the proper ODBC environment before configuring data sources. See "Environment Configuration" for basic setup information and "Environment Variables" for more detail about this procedure.

Data sources are stored in the system information file (by default, odbc.ini). If you have a Motif GUI environment on UNIX or Linux, you can configure and modify data sources through the DataDirect ODBC Data Source Administrator for UNIX/Linux (the UNIX ODBC Administrator) using a driver Setup dialog box, as described in the following procedure. (See "Configuration Through the UNIX ODBC Administrator" for a detailed explanation of the Administrator.)

If you do not have a GUI environment, you can configure and modify data sources directly by editing the system information file and storing default connection values there. See "Configuration Through the System Information File" for detailed information about the specific steps necessary to configure a data source.

   

Table 15-1 lists the connection values, in the form of connection string attributes, that must be used in the system information file. Note that only the long name of the attribute can be used in the file.

Windows

On Windows, data sources are stored in the Windows Registry. You can configure and modify data sources through the ODBC Administrator using a driver Setup dialog box, as described in the following section.

Configuration

Default connection values are specified through the options on the tabs of the Setup dialog box. Connection string attributes that override these options have the same names as the options unless noted otherwise. The connection string attribute name does not have spaces between the words. For example, the option name Application Using Threads is equivalent to the connection string attribute name ApplicationUsingThreads.

NOTE: This book shows dialog box images that are specific to Windows. If you are using the drivers in the UNIX/Linux environments, the dialog box that you see may differ slightly from the Windows version. Windows-only and UNIX-only connection options are specifically noted by icons in the Setup dialog box descriptions.

By default, edit boxes and drop-down lists on the Setup dialog box are empty unless a specific default is otherwise noted.

To configure a Text data source:

  1. Start the ODBC Administrator:


    • On Windows, start the ODBC Administrator by selecting the icon from the DataDirect program group.


    • On UNIX, change to the install_dir/tools directory and, at a command prompt, enter:
    • odbcadmin

      where install_dir is the path to the product installation directory.

  2. Select a tab:
    • User DSN: If you are configuring an existing user data source, select the data source name and click Configure to display the driver Setup dialog box.
    • If you are configuring a new user data source, click Add to display a list of installed drivers. Select the driver and click Finish to display the driver Setup dialog box.



    • System DSN: If you are configuring an existing system data source, select the data source name and click Configure to display the driver Setup dialog box.
    • If you are configuring a new system data source, click Add to display a list of installed drivers. Select the driver and click Finish to display the driver Setup dialog box.

    • File DSN: If you are configuring an existing file data source, select the data source file and click Configure to display the driver Setup dialog box.
    • If you are configuring a new file data source, click Add to display a list of installed drivers. Select the driver and click Advanced to specify attributes; otherwise, click Next to proceed. Specify a name for the data source and click Next. Verify the data source information; then, click Finish to display the driver Setup dialog box.

      The General tab of the Setup dialog box appears by default.


      The General tab of the ODBC Text Driver Setup dialog box

      NOTE: The General tab displays only fields that are required for creating a data source. The fields on all other tabs are optional, unless noted otherwise.

  3. On the General tab, provide the following information; then, click Apply.
  4. Data Source Name: Type a string that identifies this Text data source configuration. Examples include Accounting or Text Files.

    Description: Type an optional long description of a data source name. For example, My Accounting Files or My Text Files in the Accounting Directory.

    Database Directory: Type the directory in which the text files are stored. If none is specified, the current working directory is used.

    The equivalent connection string attribute is Database.

    Default Table Type: Select the type of text file (table): comma-separated, tab-separated, character-separated, fixed length, or stream. This value tells the driver the default type, which is used when creating a new table and opening an undefined table.

    The equivalent connection string attribute is TableType.

    Delimiter Character: Type the character used as a delimiter for character-separated files. It can be any printable character except for single and double quotes. The default is a comma (,).

    The equivalent connection string attribute is Delimiter.

    Column Names in First Line: Select this check box to tell the driver to look for column names in the first line of the file.

    NOTE: The Default Table Type, Delimiter Character, and Column Names in First Line settings apply only to tables not previously defined. These fields also determine the attributes of new tables created with the Create Table statement.

    The equivalent connection string attribute is FirstLineNames.

  5. Optionally, click the Advanced tab to specify data source settings.

  6. The Advanced tab of the ODBC Text Driver Setup dialog box

    On this tab, provide any of the following optional information; then, click Apply.

    Rows to Scan: Type the number of rows in a text file that the driver scans to determine the data types in the file. If the value is 0, all rows in the file are scanned. The default is 25.

    The equivalent connection string attribute is ScanRows.

    Action for Undefined Tables: Select one of the two options in this group to indicate which action the driver takes when it encounters a file that has not been defined. Select the Prompt for Definition option if you want the driver to prompt the user when it encounters a file whose format is not defined. Otherwise, select the Guess Definition option; in this case, the driver guesses the file's format.

    The equivalent connection string attribute is UndefinedTable.

    Include Files with Matching Extensions: Select this check box to tell the driver to return files with a given extension in addition to the files specified in the Data File Extension field. Then, specify the types of files in the Extension List field.



    Extension List: If you selected the Include Files with Matching Extensions check box, type a comma-separated list of extensions of files you want returned. To have files with no extensions returned, specify NONE. For example, if some of your files have the extensions TXT and CSV and others have no extension, specify TXT,CSV,NONE.

    By default, when an application requests a list of tables, only files that have been defined are returned.

    The equivalent connection string attribute is ExtraExtensions.

    File Open Cache: Type an integer value that specifies the maximum number of unused file opens to cache. For example, the value 4 specifies that when a user opens and closes four files, the files are not actually closed. The driver keeps them open so that if another query uses one of these files, the driver does not have to perform another open, which degrades performance. The advantage of file open caching is increased performance. The disadvantage is that a user who tries to open the file exclusively may get a locking conflict even though no one appears to have the file open. The default is 0, which means no file open caching.

    Cache Size: Type the number of 64 KB blocks the driver uses to cache database records. The greater the number of blocks, the better the performance. The maximum number of blocks you can set depends on the system memory available. If the cache size is greater than 0, when browsing backwards, you cannot see updates made by other users until you run the Select statement again. The default is 4.

    Data File Extension: Type the file extension to use for data files. The default value is TXT. This value cannot exceed three characters. The Data File Extension setting is used for all Create Table statements. Sending a Create Table using an extension other than the Data File Extension setting causes an error.

    In other SQL statements, such as Select or Insert, users can specify an extension other than the Data File Extension setting. The Data File Extension setting is used when no extension is specified.

    Decimal Symbol: Type the decimal separator used when data is stored. Valid values are a comma or a period. The international decimal symbol (.), which is the default, must be used in DML statements and parameter buffers.

    Century Boundary: Type the cutoff year for century inference when converting two-digit dates to four-digit dates. Two-digit dates that are less than the specified year number will be converted to 20xx. Two-digit dates greater than or equal to the number are converted to 19xx. The default value is 20. For example, using the default value, a date of 19 will be interpreted as 2019 and a date of 21 is interpreted as 1921.

    International Sort: Select this check box to use international sort order as defined by your operating system when you issue a Select statement with an Order By clause. This order is always alphabetic, regardless of case; the letters are sorted as "A, b, C." Refer to your operating system documentation concerning the sorting of accented characters.

    If this check box is cleared (the default), ASCII sort order is used. This order sorts items alphabetically with uppercase letters preceding lowercase letters. For example, "A, b, C" is sorted as "A, C, b."

    The equivalent connection string attribute is IntlSort.



    Use Long Qualifiers: Select this check box to specify that the driver uses long path names. In this case, path names can be a maximum of 255 characters. If the check box is cleared (the default), path names can be a maximum of 128 characters.

    Allow Update and Delete: Select this check box to allow Update and Delete statements. Because Update and Delete statements cause immediate changes to a text file, only one connection at a time can operate on a file. When this check box is selected, text files are opened exclusively by the current connection. Each update and delete on a text file can cause significant changes to the file, and performance may be degraded. Consider a more appropriate database form if performance is a significant factor.

    The equivalent connection string attribute is AllowUpdateAndDelete.

    Application Using Threads: Select this check box to ensure that the driver works with multi-threaded applications. You can clear this check box when using the driver with single-threaded applications. Turning off this setting avoids additional processing required for ODBC thread-safety standards. By default, the check box is selected.



    IANAAppCodePage: For a list of valid values for this option, refer to "Values for the Attribute IANAAppCodePage" in the DataDirect Connect for ODBC and Connect XE for ODBC Reference. You need to specify a value for this option if your application is not Unicode-enabled and/or if your database character set is not Unicode (refer to "Internationalization, Localization, and Unicode" in the DataDirect Connect for ODBC and Connect XE for ODBC Reference for details). The value you specify must match the database character encoding and the system locale.

    The Driver Manager checks for the value of IANAAppCodePage in the following order:

    • In the connection string
    • In the Data Source section of the system information file (odbc.ini)
    • In the ODBC section of the system information file (odbc.ini)

    If no IANAAppCodePage value is found, the driver uses the default value of 4 (ISO 8859-1 Latin-1).

    Define: Click Define to define the structure of your text files as described in "Defining Table Structure on Windows".



    Translate: Click Translate to display the Select Translator dialog box, which lists the translators specified in the ODBC Translators section of the Registry. DataDirect provides a translator named OEM to ANSI that translates your data from the IBM PC character set to the ANSI character set.

    Select a translator; then, click OK to close this dialog box and perform the translation.

  7. At any point during the configuration process, you can click Test Connect to attempt to connect to the data source using the connection properties specified in the driver Setup dialog box.
    • If the driver can connect, it releases the connection and displays a connection established message. Click OK.
    • If the driver cannot connect because of an incorrect environment or connection value, it displays an appropriate error message. Click OK.
  8. Click OK or Cancel. If you click OK, the values you have specified become the defaults when you connect to the data source. You can change these defaults by using this procedure to reconfigure your data source. You can override these defaults by connecting to the data source using a connection string with alternate values.