Once the driver has been installed, in order for an application to be able to connect to {es} through ODBC, a set of configuration parameters must be provided to the driver. Depending on the application, there are generally three ways of providing these parameters:
* through a connection string;
* using a User DSN or System DSN;
* through a File DSN.
DSN (_data source name_) is a generic name given to the set of parameters an ODBC driver needs to connect to a database.
We will refer to these parameters as _connection parameters_ or _DSN_ (despite some of these parameters configuring some other aspects of a driver's functions; e.g. logging, buffer sizes...).
Using a DSN is the most widely used, simplest and safest way of performing the driver configuration. Constructing a connection string, on the other hand, is the most crude way and consequently the least common method.
We will focus on DSN usage only.
[[data-source-administrator]]
==== 1. Launching ODBC Data Source Administrator
For DSN management, ODBC provides the _ODBC Data Source Administrator_ application, readily installed on all recent desktop Windows operating systems.
- The 32-bit version of the Odbcad32.exe file is located in the `%systemdrive%\Windows\SysWoW64` folder.
- The 64-bit version of the Odbcad32.exe file is located in the `%systemdrive%\Windows\System32` folder.
To launch it, open the search menu - _Win + S_ - and type "ODBC Data Sources (64-bit)" or "ODBC Data Sources (32-bit)" and press _Enter_:
[[launch_administrator]]
.Launching ODBC Data Source Administrator
image:images/sql/odbc/launch_administrator.png[]
Once launched, you can verify that the driver was installed correctly by clicking on the _Drivers_ tab of the ODBC Data Source Administrator and checking that _Elasticsearch Driver_ is present in the list of installed drivers.
You should also see the version number of the installed driver.
[[administrator_drivers]]
.Drivers tab
image:images/sql/odbc/administrator_drivers.png[]
[[dsn-configuration]]
==== 2. Configure a DSN
The next step is to configure a DSN. You can choose between the following options mapped on the first three tabs of the Administrator application:
* User DSN
+
The connections configured under this tab are only available to the currently logged in user. Each of these DSNs are referred to by a chosen arbitrary name (typically a host or cluster name).
+
The actual set of parameters making up the DSN is stored through the driver in the system registry. Thus, a user will later only need to provide an application with the DSN name in order to connect to the configured {es} instance.
+
* System DSN
+
Similar to a User DSN, except that the connections configured under this tab will be available to all the users configured on the system.
* File DSN
+
This tab contains functionality that will allow to have one set of connection parameters written into a file, rather then the Registry.
+
Such a file can be then shared among multiple systems and the user will need to specify the path to it, in order to have the application connect to the configured {es} instance.
The configuration steps are similar for all the above points. Following is an example of configuring a System DSN.
In case the server uses a certificate that is not part of the PKI, for example using a self-signed certificate, you can configure the path to a X.509 certificate file that will be used by the driver to validate server's offered certificate.
The driver will only read the contents of the file just before a connection is attempted. See <<connection_testing>> section further on how to check the validity of the provided parameters.
For troubleshooting purposes, the {odbc} offers functionality to log the API calls that an application makes; this is enabled in the Administrator application:
However, this only logs the ODBC API calls made by the application into the _Driver Manager_ and not those made by the _Driver Manager_ into the driver itself. To enable logging of the calls that the driver receives, as well as internal driver processing events, you can enable driver's logging on Editor's _Logging_ tab:
* Enable Logging?
+
Ticking this will enable driver's logging. A logging directory is also mandatory when this option is enabled (see the next option).
However the specified logging directory will be saved in the DSN if provided, even if logging is disabled.
+
* Log Directory
+
Here is to specify which directory to write the log files in.
+
NOTE: The driver will create *one log file per connection*, for those connections that generate logging messages.
+
* Log Level
+
Configure the verbosity of the logs.
+
[[administrator_logging]]
.Enable driver logging
image:images/sql/odbc/dsn_editor_logging.png[]
+
When authentication is enabled, the password will be redacted from the logs.
NOTE: Debug-logging can quickly lead to the creation of many very large files and generate significant processing overhead. Only enable if
instructed so and preferably only when fetching low volumes of data.
[float]
[[connection_testing]]
===== 2.5 Testing the connection
Once the _Hostname_, the _Port_ (if different from implicit default) and the SSL options are configured, you can test if the provided
parameters are correct by pressing the _Test Connection_ button. This will instruct the driver to connect to the {es} instance and perform
a simple SQL test query. (This will thus require a running {es} instance with the SQL plugin enabled.)
[[dsn_editor_conntest]]
.Connection testing
image:images/sql/odbc/dsn_editor_conntest.png[]
NOTE: When connection testing, all the configured parameters are taken into account, including the logging configuration. This will allow
early detection of potential file/directory access rights conflicts.
See <<alternative_logging>> section further for an alternative way of configuring the logging.
[[available-dsn]]
==== 3. DSN is available
Once everything is in place, pressing the _Save_ button will store the configuration into the chosen destination (Registry or file).
Before saving a DSN configuration the provided file/directory paths are verified to be valid on the current system. The DSN editor
will however not verify in any way the validity or reachability of the configured _Hostname_ : _Port_. See <<connection_testing>>
for an exhaustive check.
If everything is correct, the name of the newly created DSN will be listed as available to use: