Wiki source code of Ajout Pilote JDBC

Last modified by jhurst on 2022/04/28 16:42

Show last authors
1 {{ddtoc/}}
2
3 This document describes the process to add a new JDBC data base driver to DigDash Enterprise.
4
5 = Requirement =
6
7 The JDBC driver as a JAR file, and its documentation
8
9 = Installation =
10
11 == Driver files deployment ==
12
13 1. (optional, if the webapps have not been already deployed). Start your DigDash Enterprise Server and wait for the webapps to be fully deployed
14 1. Stop the server
15 1. copy the driver's JAR file into the following folders:
16 **<DD Install>/apache-tomcat/webapps/ddenterpriseapi/WEB-INF/lib
17 <DD Install>/apache-tomcat/webapps/studio/WEB-INF/lib**
18 1. The JDBC driver must be registered within DigDash Enterprise Server.
19
20 == Registering the driver in Digdash Enterprise ==
21
22 Edit the following file :
23
24 **<DD Install>\apache-tomcat\webapps\ddenterpriseapi\WEB-INF\classes\resources\config\sqldriverrepository.xml**
25
26 Add an XML entry to the **sqldriverrepository.xml **that looks like the following sample:
27
28 {{code language="XML" cssClass="notranslate"}}
29 <SQLDriver id="MY_DRIVER"
30 name="My Driver"
31 url="mydriver:"
32 manufacturer="My Driver Company"
33 class="com.mydriver.MyDriver"
34 urlsample="jdbc:mydriver:<database>?<options>"
35 availability="both">
36 <properties></properties>
37 </SQLDriver>
38 {{/code}}
39
40 (% class="box warningmessage" %)
41 (((
42 //Important: Some characters are reserved in XML: '**&**', '**"**', '**<**' or '**>**'. If you need these characters you must encode them into their corresponding XML entity.//
43 )))
44
45 //Corresponding XML entities~://
46
47 * **&** => **&amp;**
48 * **"** => **&quot;**
49 * **<** => **&lt;**
50 * **>** => **&gt;**
51
52 Example:
53
54 (% class="box" %)
55 (((
56 * (WRONG) urlsample="jdbc:mydriver:dbtest?opt1=0&opt2="value""
57 * (RIGHT) urlsample="jdbc:mydriver:dbtest?opt1=0&amp;opt2=&quot;value&quot;"
58 )))
59
60 Parameters:
61
62 * **id**: An identifier used by DigDash internally, choose any non existent string, the convention is uppercase, no spaces
63 * **name**: The driver's name to be displayed in the user interface of the administration console
64 * **url**: jdbc URL prefix (without "jdbc:"). See driver's documentation
65 * **manufacturer**: Name of the driver's vendor/developer
66 * **class**: java class path of the main driver class. See driver's documentation.
67 Optional: JDBC drivers compliant with JDBC 4 do not need a driver class. Keep the class attribute empty (class="") in that case.
68 * **urlsample**: User friendly URL sample for the user interface of the administration console.
69 * **availability**: reserved. Leave it at "both".
70
71 (% class="box warningmessage" %)
72 (((
73 //Important: The deployment is lost when upgrading ddenterpriseapi.war file.//
74 //Please follow the deployment guide each time you upgrade DigDash Enterprise//
75 )))
76
77 You can find some sample of XML for drivers not provided in DigDash enterprise in **sqldriverrepository.xml** file.
78
79 == Specific properties (advanced) ==
80
81 You can specify secific properties on some JDBC drivers. These properties are written inside the <properties></properties> tag, under the following format:
82
83 {{code cssClass="XML" language="XML"}}
84 <properties>
85
86 <property name="property_name" value="property_value" ></property>
87
88 <properties>
89 {{/code}}
90
91 Supported properties are:
92
93 === FORCE_FORWARD_ONLY (undefined | false | true) ===
94
95 Description: specifies the type of JDBC result set cursor used by the Studio for the preview of the SQL query results. By default the Studio uses a TYPE_INSENTIVE_SCROLL cursor to preview the results, but some of the databases do not support this type of cursor. If your driver or database only supports TYPE_FORWARD_ONLY cursors you can specify it with FORCE_FORWARD_ONLY property. Possible values:
96
97 * **false** (or **undefined property**): The type of cursor is automatic, TYPE_SCROLL_INSENTIVE in most of the cases, except for HIVE, IMPALA and SAPHANA
98 * **true**: The type of cursor used in the Studio is TYPE_FORWARD_ONLY
99
100 === PING_SQL (undefined | SQL query | empty string) ===
101
102 Description: DigDash Enterprise tests the connection with the database by using the JDBC method **Connection.isValid()**. On some drivers this method does not work. In that case DigDash uses an alternative method to “ping” the database, usually by sending a “select 1” statement.
103
104 The PING_SQL property allows you to specify this SQL statement depending on your driver or database. Possible values:
105
106 * **Undefined property**: The alternative ping query is automatically decided by DigDash: “select 1” except for ORACLE, FIREBIRD, SAPHANA, DB2_AS400 or DB2 drivers
107 * **SQL query (not empty)**: the specified query is used to ping the databse. Example:
108 <property name="PING_SQL" value="select 1 from all_tables" />
109 * **Empty string**: Special case used to deactivate the ping in the case the JDBC method Connection.isValid() fails. The database is considered to be always accessible. Example:
110 <property name="PING_SQL" value="" />
111
112 === USE_FETCH_FIRST_IN_STUDIO (undefined | false | true) ===
113
114 Description: This property is used only for preview the SQL result in the data source configuration dialog (Studio). It modifies the query by adding “FETCH FIRST n ROWS ONLY” to it (n is replaced byt the number of preview rows). It is useful for drivers that do not support JDBC’s **Statement.setMaxRows[[image:icon:thumb_down]]**, for example AS400 JDBC driver. Possible values:
115
116 * **false** (or **undefined property**): The preview limit is defined by using JDBC method **Statement.setMaxRows[[image:icon:thumb_down]]**
117 * **true**: Preview limit is defined by adding FERTCH FIRST n ROWS ONLY to the SQL in the Studio.
118
119 === FORBID_POOL_CONNECTION (undefined | false | true) ===
120
121 Description: Prevents DigDash Enterprise from using a JDBC connection pool for this driver. A JDBC connection pool optimizes access to the data base by keeping connections in an opened state, and reuse them for different queries. In some cases it is preferred to not use a JDBC connection pool, for example to ensure that connections will not stay opened too long on the data base after they have been used for a query. This property answers that need. Possible values:
122
123 * **false** (or **undefined property**): A JDBC connection pool may be used by the driver
124 * **true**: The JDBC connection pool will not be used by the driver and each SQL query will have its own connection.
125
126 === POOL_VALIDATION_QUERY (undefined | SQL query) ===
127
128 Description: Specify a validation query used by the JDBC Apache DBCP2 connection pool. Some drivers do not specify this query (eg. « select 1 ») and can malfunction when a connection is created by the JDBC connection pool. This property is similar to the validationQuery property which is configured in Apache DBCP2 pool configuration. Possible values:
129
130 * **undefined**: No specified validation query for this driver. The connection pool will use the default validation query, if it exists.
131 * **non-empty SQL query **: The specified query will be use to test the validity of a connection obtained from the Apache DBCP connection pool. (Example : select 1)
132
133 === DEFAULT_FETCH_SIZE (undefined | number) ===
134
135 Description: Specify a maximum number of rows to be retrieve at once by DigDash Enterprise. Some JDBC drivers (eg. Postgresql) retrieve all result rows of a request at once, instead of streaming the result to be consumed by DigDash Enterprise. This can lead to a higher memory usage (bigger memory buffer needed) and to prevent cancelling the fetch of the result mid-time. This parameter can help avoiding this case by specifying a reasonable number of rows to retrieve (eg. 100). For example, DEFAULT_FETCH_SIZE = 1000 will retrieve the first 1000 rows of result, and when DigDash will need the 1001st row, the driver will retrieve the next 1000 rows, and so on. This parameter can also by specified directly in the data source configuration (advanced) in the Studio.
136
137 = Pre-configured drivers, not included =
138
139 The following Database connectivities are available in DigDash Enterprise by default, but their JDBC driver is not included and need additional installation:
140
141 == MySQL ==
142
143 DigDash Enterprise can connect to a MySQL 5.5 (and after) database by using **MariaDB Java connector** driver. In most of the cases, this driver is enough to connect to a MySQL (and MariaDB) database. However, to connect to a previous version of MySQL, or to use specific features of the native MySQL JDBC driver, you will need the MySQL driver corresponding to your version of the database. For these cases, you must download the driver from MySQL website: [[https:~~/~~/dev.mysql.com/downloads/connector/j/>>url:https://dev.mysql.com/downloads/connector/j/]]
144
145 (% class="box warningmessage" %)
146 (((
147 The MariaDB driver included in DigDash Enterprise handles **jdbc:mysql:~/~/** et **jdbc:mariadb:~/~/** connections. To use the MySQL native JDBC driver you must remove MariaDB driver from the **ddenterpriseapi **and s**tudio **webapps. The file to remove is **mariadb-java-client-*.jar**. Keeping both drivers can lead to issues when connecting to MySQL.
148 However, it is possible to keep the MariaDB driver, for the case when you have a MySQL database and a MariaDB database. You need to add the parameter **&disableMariaDbDriver** in the connection string to your MySQL database (jdbc:mysql:~/~/...&disableMariaDbDriver). More information on the MariaDB website: [[https:~~/~~/mariadb.com/kb/en/about-mariadb-connector-j/>>url:https://mariadb.com/kb/en/about-mariadb-connector-j/]].
149 )))
150
151 (% class="box warningmessage" %)
152 (((
153 If you decide to install the MySQL driver, you can notice that a definition for it already exist in the file **sqldriverrepository.xml** included in DigDash Enterprise (see XML below), but it is commented out. You need to un-comment this XML definition (and also comment the one for MariaDB driver).
154 This definition concerns the newer version of the MySQL driver, from MySQL Connector/J 8.0. Recent MySQL drivers are compatible with all version of MySQL database. However, if you decide to install an older version you need to remove the class property from this definition, and then rename the classOld property into class, because the driver's class name has changed in Connector/J 8.0. In any case, read the documentation corresponding to the driver you install.
155
156 {{code cssClass="XML" language="XML"}}
157 <SQLDriver id="MYSQL" name="MySQL"
158 url="mysql://"
159 class="com.mysql.cj.jdbc.Driver"
160 classOld="com.mysql.jdbc.Driver"
161 manufacturer="MySQL"
162 urlsample="$ui.DataBase.MySqlSampleUrl"
163 availability="both">
164 <properties>
165 </properties>
166 </SQLDriver>
167
168 {{/code}}
169 )))
170
171 == Teradata ==
172
173 The JDBC driver for Teradata can be downloaded on Teradata website: [[https:~~/~~/downloads.teradata.com/download/connectivity/jdbc-driver>>url:https://downloads.teradata.com/download/connectivity/jdbc-driver]]. The download needs a user account.
174
175 == IBM DB2 ==
176
177 The JDBC driver for IBM DB2 can be downloaded on IBM website: [[https:~~/~~/www.ibm.com/support/pages/db2-jdbc-driver-versions-and-downloads>>url:https://www.ibm.com/support/pages/db2-jdbc-driver-versions-and-downloads]]. The download needs a user account. The driver consist in 2 .jar files, one for the driver, one for the license. You can also find these files in your DB2 installation.
178
179 == Microsoft SQL Server ==
180
181 DigDash Enterprise is packaged with jTDS, an open source JDBC driver compatible with Microsoft SQL Server. However, if you want to use specific features of the Microsoft SQL Server driver, you need to download it from Microsoft website: [[https:~~/~~/docs.microsoft.com/fr-fr/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server?view=sql-server-ver15>>url:https://docs.microsoft.com/fr-fr/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server?view=sql-server-ver15]].
182
183 == Hadoop Hive ==
184
185 Installing Hadoop Hive driver depends on your Hadoop installation (Example: Cloudera, Hortonworks...). It it recommended to use the corresponding driver included with your Hadoop Installation (non exhaustively) :
186
187 * Cloudera : [[https:~~/~~/www.cloudera.com/downloads/connectors/hive/jdbc/2-6-5.html>>url:https://www.cloudera.com/downloads/connectors/hive/jdbc/2-6-5.html]]
188 * Hortonworks : [[https:~~/~~/www.progress.com/jdbc/hortonworks-hive>>url:https://www.progress.com/jdbc/hortonworks-hive]]
189
190 == Google BigQuery ==
191
192 Read the specific document about [[BigQuery Connector>>doc:Digdash.deployment.Connectivity_Database.bigquery_connector.WebHome]] in Digdash Enterprise.
193
194 == SAP HANA ==
195
196 Read the specific document about [[SAP HANA>>doc:Digdash.deployment.Connectivity_Database.saphana_connector.WebHome]] in Digdash Enterprise.