Using DLI for Data Analysis
Interconnect the customer service system with DLI to conduct trade statistics analysis on OBS data.
You can access DLI using ODBC APIs on the local PC running a Windows OS.
Prerequisites
Before using the ODBC interface to access DLI, download the ODBC driver release package as follows:
- Log in to the DLI management console.
- Click Common links in the upper right corner.
- In the Download Driver area, click Download.
ODBC driver release package structure
- The ODBC driver release package of DLI is dli-odbc-v1.1.1_Release.zip.
- Figure 1 shows the directory structure of the ODBC driver release package.
In the preceding figure:
- The example directory provides C and C# sample code for client applications.
- The windows directory refers to the ODBC driver installation directory.
- The dli.version file refers to the driver version.
- Figure 2 shows the directory structure of DLI_odbc\windows.
In the preceding figure:
- The log directory stores ODBC driver logs.
- The jars directory includes the Java package on which the ODBC driver depends.
- odbcreg.exe refers to the driver and data source registration tool.
- odbc.ini refers to the driver configuration file, which is used to register data sources.
- log.properties refers to the log configuration file, which is used to configure the log output level and output path.
- dliodbc.dll refers to the ODBC dynamic driver library.
Environment Requirements
- Windows 2012 or later
- Java 1.8
- Visual Studio 2012 (used to compile and run sample programs)
Environment Preparation
- Install the Java operating environment.
Obtain the 32-bit installation package of Java 1.8 from the Java official website. The download path is as follows:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
For details, see Figure 3.
NOTE: After the installation is complete, record the Java installation directory, for example: C:\Program Files (x86)\java\jdk1.8.0_161.
- Install the software Visual Studio 2012 required for installing and compiling the example code.
Installing the ODBC Driver
- Decompress the installation package.
Decompress dli-odbc-v1.1.1_Release.zip to the root directory of drive C.
NOTE: The installation directory can be adjusted. You are advised to install it in the root directory of disk C.
- Register the ODBC driver.
- In the PC running the Windows OS, click Start, enter cmd in the search box, and press Enter. In the command prompt window, access the windows directory under the directory where dli-odbc-v1.1.1_Release.zip is decompressed. For example: C:\DLI_odbc\windows.
- Run the following command:
.\odbcreg /i DLIODBC dliodbc.dll C:\DLI_odbc\windows
NOTE: - DLIODBC refers to the name of the registered DLI ODBC driver.
- C:\DLI_odbc\windows refers to the windows directory under the directory where DLI-odbc-v1.1.1_Release.zip is decompressed. You can change the directory according to the actual conditions.
- Enter y as prompted.
The command output is as follows:
ODBCREG - to register or unregister ODBC driver Proceeding to register... driver: DLIODBC dll: dliodbc.dll path: C:\DLI_odbc\windows Confirm(y/n) DLIODBC installed/registered successfully - View the registry. Click Start, enter cmd in the search box, and press Enter. In the command prompt window, enter regedit and press Enter to open the registry editor.
NOTE: - Check that driver DLIODBC exists in HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI of the registry.
- The registry path of the 32-bit Windows OS is HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI.
Configuring Environment Variables
- Configure environment variables. Configure and modify the following system variables:
- Variable: JAVA_CLIENT_DLL Value: C:\Program Files (x86)\java\jdk1.8.0_161\jre\bin\client\jvm.dll
NOTE: Configure the variable based on the actual installation directory.
- Variable: Path Value: C:\Program Files (x86)\java\jdk1.8.0_161\jre\bin\client;%Path%
NOTE: Configure the variable based on the actual installation directory.
- Variable: JAVA_CLIENT_DLL
- Restart the system for the settings to take effect.
Configuring Log Parameters
Open the log.properties file, for example, C:\DLI_odbc\windows\log.properties, in the ODBC installation directory.
Modify the following parameters:
- Log output level log4cplus.rootLogger=INFO,DLILog
NOTE: You are advised to set the level to INFO. To locate a fault, you can change the value to DEBUG.
- Log output path:
log4cplus.appender.DLILog.File=C:\DLI_odbc\windows\log\DLI_odbc.log
NOTE: You are advised to set the log output path to the log directory in the installation path. Set this parameter based on the actual installation path.
Configuring Data Sources
- Prepare the data source configuration file.
Modify the odbc.ini file in the C:\DLI_odbc\windows directory as follows:
[DLI] DRIVER=DLIODBC DATABASE=#### Configure the actual DLI database name. HOST=DLI.cn-north-1.myhuaweicloud.com PORT=-1 PROJECTID=#### Set this parameter based on the actual account used to log in to DLI. QUEUENAME=default #### Set this parameter based on the actual queue created in DLI. AK=#### Set this parameter based on the actual account used to log in to DLI. SK=#### Set this parameter based on the actual account used to log in to DLI. REGION=dli.cn-north-1.myhuaweicloud.com AUTHMODE=1 SVCNAME=DLI CONFFILE=odbc.ini USEPROXY=0
- Add the user data source.
- Run the following command: .\odbcreg.exe /d DLIODBCUserDS C:\DLI_odbc\windows\odbc.ini
NOTE: DLIODBCUserDS refers to the user data source name, which is used in applications.
- After confirming that the print is consistent with the content in the odbc.ini file, enter y. The command output is as follows:
ODBCREG - to register or unregister ODBC driver Attribute to be register are: DRIVER = DLIODBC DATABASE = #### HOST = dli.cn-north-1.myhuaweicloud.com PORT = -1 PROJECTID = #### QUEUENAME = default AK = #### SK = #### REGION = dli.cn-north-1.myhuaweicloud.com AUTHMODE = 1 SVCNAME = DLI CONFFILE = odbc.ini Confirm(y/n) Add datasource .
- Run the following command:
- View the registry. Click Start, enter cmd in the search box, and press Enter. In the command prompt window, enter regedit and press Enter to open the registry editor.
Check whether HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\DLIODBCUserDS exists.
- Add the system data source.
- Run the following command: .\odbcreg.exe /s DLIODBCSysDS C:\DLI_odbc\windows\odbc.ini
NOTE: DLIODBCSysDS refers to the system data source name, which is used in applications.
- After confirming that the print is consistent with the content in the odbc.ini file, enter y. The command output is as follows:
ODBCREG - to register or unregister ODBC driver Attribute to be register are: DRIVER = DLIODBC DATABASE = #### HOST = dli.cn-north-1.myhuaweicloud.com PORT = -1 PROJECTID = #### QUEUENAME = default AK = #### SK = #### REGION = dli.cn-north-1.myhuaweicloud.com AUTHMODE = 0 SVCNAME = DLI CONFFILE = odbc.ini Confirm(y/n) Add datasource .
- Run the following command:
- View the registry. Click Start, enter cmd in the search box, and press Enter. In the command prompt window, enter regedit and press Enter to open the registry editor.
Check whether HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\DLIODBCSysDS exists.
Accessing DLI Based on the ODBC Driver Through Code
- Create databases and tables, including the trade statistics database, trade detail record table, and basic information table.
- Conduct data query.
A C# code example is as follows:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data; using System.Data.Odbc; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string connectionString = "dsn=DLIODBCds"; string queryString = "show tables;";//show tables; You can use the corresponding DDL or DML statement instead. OdbcCommand command = new OdbcCommand(queryString); using (OdbcConnection connection = new OdbcConnection(connectionString)) { OdbcDataReader reader; try { command.Connection = connection; connection.Open(); reader = command.ExecuteReader(); while (reader.Read()) { Console.WriteLine("\t{0}\t{1}\t{2}", reader[0], reader[1], reader[2]); } reader.Dispose(); reader.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } command.Dispose(); } } }
During the query, replace the name of dns specified in string connectionString with the DLI ODBC driver.
Last Article: Uploading Incremental Data



Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.