Files
doc-exports/docs/dli/dev/dli_09_0127.html
Su, Xiaomeng 89b6bedc33 dli_dev_0104_version
Reviewed-by: Rechenburg, Matthias <matthias.rechenburg@t-systems.com>
Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
2024-01-08 15:25:35 +00:00

465 lines
45 KiB
HTML

<a name="dli_09_0127"></a><a name="dli_09_0127"></a>
<h1 class="topictitle1">Submitting a Job Using JDBC</h1>
<div id="body8662426"><div class="section" id="dli_09_0127__en-us_topic_0093946957_section4984415014219"><h4 class="sectiontitle">Scenario</h4><p id="dli_09_0127__en-us_topic_0093946957_p18381667515">In Linux or Windows, you can connect to the DLI server using JDBC.</p>
<div class="note" id="dli_09_0127__note2546173315568"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dli_09_0127__p19546173385615">The job submitted by using JDBC to connect to DLI runs on the Spark engine.</p>
</div></div>
<div class="p" id="dli_09_0127__en-us_topic_0093946957_p94251106521">DLI supports 13 data types. Each type can be mapped to a JDBC type. If JDBC is used to connect to the server, you must use the mapped Java type. <a href="#dli_09_0127__en-us_topic_0093946957_table74891852105113">Table 1</a> describes the mapping relationships.
<div class="tablenoborder"><a name="dli_09_0127__en-us_topic_0093946957_table74891852105113"></a><a name="en-us_topic_0093946957_table74891852105113"></a><table cellpadding="4" cellspacing="0" summary="" id="dli_09_0127__en-us_topic_0093946957_table74891852105113" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Data type mapping</caption><thead align="left"><tr id="dli_09_0127__en-us_topic_0093946957_row145045529518"><th align="left" class="cellrowborder" valign="top" width="33.083308330833084%" id="mcps1.3.1.4.2.2.4.1.1"><p id="dli_09_0127__en-us_topic_0093946957_p7506185265115">DLI Data Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.83338333833383%" id="mcps1.3.1.4.2.2.4.1.2"><p id="dli_09_0127__en-us_topic_0093946957_p2050825215515">JDBC Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.083308330833084%" id="mcps1.3.1.4.2.2.4.1.3"><p id="dli_09_0127__en-us_topic_0093946957_p11512135215118">Java Type</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_09_0127__en-us_topic_0093946957_row13515105235119"><td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p14519205235114">INT</p>
</td>
<td class="cellrowborder" valign="top" width="33.83338333833383%" headers="mcps1.3.1.4.2.2.4.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p152114529514">INTEGER</p>
</td>
<td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p10524115215110">java.lang.Integer</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row17525152135110"><td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p45281652195112">STRING</p>
</td>
<td class="cellrowborder" valign="top" width="33.83338333833383%" headers="mcps1.3.1.4.2.2.4.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p753135225113">VARCHAR</p>
</td>
<td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p1953512526518">java.lang.String</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row1853685210514"><td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p175397521512">FLOAT</p>
</td>
<td class="cellrowborder" valign="top" width="33.83338333833383%" headers="mcps1.3.1.4.2.2.4.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p17541552125114">FLOAT</p>
</td>
<td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p1354419526519">java.lang.Float</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row13545952205110"><td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p0549185295115">DOUBLE</p>
</td>
<td class="cellrowborder" valign="top" width="33.83338333833383%" headers="mcps1.3.1.4.2.2.4.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p1255115529512">DOUBLE</p>
</td>
<td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p1855413529511">java.lang.Double</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row3555252145110"><td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p1557105213511">DECIMAL</p>
</td>
<td class="cellrowborder" valign="top" width="33.83338333833383%" headers="mcps1.3.1.4.2.2.4.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p1156085214511">DECIMAL</p>
</td>
<td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p185631552175118">java.math.BigDecimal</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row456475215515"><td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p13566115216519">BOOLEAN</p>
</td>
<td class="cellrowborder" valign="top" width="33.83338333833383%" headers="mcps1.3.1.4.2.2.4.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p15681852145112">BOOLEAN</p>
</td>
<td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p7570165218518">java.lang.Boolean</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row35721652135120"><td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p1257415211512">SMALLINT/SHORT</p>
</td>
<td class="cellrowborder" valign="top" width="33.83338333833383%" headers="mcps1.3.1.4.2.2.4.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p05751752155115">SMALLINT</p>
</td>
<td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p14578052135119">java.lang.Short</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row18580155285116"><td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p11583175295113">TINYINT</p>
</td>
<td class="cellrowborder" valign="top" width="33.83338333833383%" headers="mcps1.3.1.4.2.2.4.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p9585155213512">TINYINT</p>
</td>
<td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p958835285110">java.lang.Short</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row35897527518"><td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p659115220512">BIGINT/LONG</p>
</td>
<td class="cellrowborder" valign="top" width="33.83338333833383%" headers="mcps1.3.1.4.2.2.4.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p125931052115110">BIGINT</p>
</td>
<td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p195961852185115">java.lang.Long</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row1359785210512"><td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p65991652135119">TIMESTAMP</p>
</td>
<td class="cellrowborder" valign="top" width="33.83338333833383%" headers="mcps1.3.1.4.2.2.4.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p76021252155115">TIMESTAMP</p>
</td>
<td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p10605125285116">java.sql.Timestamp</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row16607352145111"><td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p146090526517">CHAR</p>
</td>
<td class="cellrowborder" valign="top" width="33.83338333833383%" headers="mcps1.3.1.4.2.2.4.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p9614115213512">CHAR</p>
</td>
<td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p1561610523516">Java.lang.Character</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row96178529512"><td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p156196521516">VARCHAR</p>
</td>
<td class="cellrowborder" valign="top" width="33.83338333833383%" headers="mcps1.3.1.4.2.2.4.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p0621165255117">VARCHAR</p>
</td>
<td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p9624135275119">java.lang.String</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row186271252195117"><td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p1563165214515">DATE</p>
</td>
<td class="cellrowborder" valign="top" width="33.83338333833383%" headers="mcps1.3.1.4.2.2.4.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p6635195218515">DATE</p>
</td>
<td class="cellrowborder" valign="top" width="33.083308330833084%" headers="mcps1.3.1.4.2.2.4.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p16381152185115">java.sql.Date</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="section" id="dli_09_0127__section12581831432"><h4 class="sectiontitle">Prerequisites</h4><p id="dli_09_0127__p158441015314">Before using JDBC, perform the following operations:</p>
<ol id="dli_09_0127__ol189969321298"><li id="dli_09_0127__dli_09_0121_li149961532192916">Getting authorized.<p id="dli_09_0127__dli_09_0121_p16317291479"><a name="dli_09_0127__dli_09_0121_li149961532192916"></a><a name="dli_09_0121_li149961532192916"></a>DLI uses the Identity and Access Management (IAM) to implement fine-grained permissions for your enterprise-level tenants. IAM provides identity authentication, permissions management, and access control, helping you securely access your resources.</p>
<p id="dli_09_0127__dli_09_0121_p188991750134717">With IAM, you can use your account to create IAM users for your employees, and assign permissions to the users to control their access to specific resource types. </p>
<p id="dli_09_0127__dli_09_0121_p13200194518338">Currently, roles (coarse-grained authorization) and policies (fine-grained authorization) are supported. </p>
</li><li id="dli_09_0127__dli_09_0121_li714994042910">Create a queue. Choose <strong id="dli_09_0127__dli_09_0121_b544120341765">Resources</strong> &gt; <strong id="dli_09_0127__dli_09_0121_b14660163713613">Queue Management</strong>. On the page displayed, click <strong id="dli_09_0127__dli_09_0121_b132671161576">Buy Queue</strong> in the upper right corner. On the <strong id="dli_09_0127__dli_09_0121_b1754622216715">Buy Queue</strong> page displayed, select <strong id="dli_09_0127__dli_09_0121_b131631011983">For general purpose</strong> for <strong id="dli_09_0127__dli_09_0121_b82061574716">Type</strong>, that is, the compute resources of the Spark job.<div class="note" id="dli_09_0127__dli_09_0121_note1970895364011"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dli_09_0127__dli_09_0121_p1717716210156">If the user who creates the queue is not an administrator, the queue can be used only after being authorized by the administrator. For details about how to assign permissions, see .</p>
</div></div>
</li></ol>
</div>
<div class="section" id="dli_09_0127__en-us_topic_0093946957_section51761783175346"><h4 class="sectiontitle">Procedure</h4><ol id="dli_09_0127__en-us_topic_0093946957_ol31954877175346"><li id="dli_09_0127__en-us_topic_0093946957_li19158445175346"><span>Install JDK 1.7 or later on the computer where JDBC is installed, and configure environment variables.</span></li><li id="dli_09_0127__en-us_topic_0093946957_li57163766145228"><span>Obtain the DLI JDBC driver package <strong id="dli_09_0127__b17103129162114"></strong><strong id="dli_09_0127__b16103829102112">dli-jdbc-&lt;version&gt;.zip</strong> by referring to <a href="dli_09_0125.html">Downloading the JDBC Driver Package</a>. Decompress the package to obtain <strong id="dli_09_0127__b13105429122118"></strong><strong id="dli_09_0127__b410552915212">dli-jdbc-&lt;version&gt;-jar-with-dependencies.jar</strong>.</span></li><li id="dli_09_0127__en-us_topic_0093946957_li57387457141357"><span>On the computer using JDBC, add <strong id="dli_09_0127__b17768164115218"></strong><strong id="dli_09_0127__b6768174172111">dli-jdbc-1.1.1-jar-with-dependencies.jar</strong> to the <strong id="dli_09_0127__b20769184132115">classpath</strong> path of the Java project.</span></li><li id="dli_09_0127__en-us_topic_0093946957_li52484676142637"><span>DLI JDBC provides two authentication modes, namely, token and AK/SK, to connect to DLI. For details about how to obtain the token and AK/SK, see <a href="dli_09_0126.html">Performing Authentication</a>.</span></li><li id="dli_09_0127__en-us_topic_0093946957_li571299514295"><span>Run the <strong id="dli_09_0127__b842352706174155">Class.forName()</strong> command to load the DLI JDBC driver.</span><p><p id="dli_09_0127__en-us_topic_0093946957_p1785388152334"><b><span class="cmdname" id="dli_09_0127__en-us_topic_0093946957_cmdname17791163104">Class.forName("com.dli.jdbc.DliDriver");</span></b></p>
</p></li><li id="dli_09_0127__en-us_topic_0093946957_li56634955143112"><span>Call the GetConnection method of DriverManager to create a connection.</span><p><p id="dli_09_0127__en-us_topic_0093946957_p35619310143157"><b><span class="cmdname" id="dli_09_0127__en-us_topic_0093946957_cmdname12443111412012">Connection conn = DriverManager.getConnection(String url, Properties info);</span></b></p>
<div class="p" id="dli_09_0127__en-us_topic_0093946957_p11924380144923">JDBC configuration items are passed using the URL. For details, see <a href="#dli_09_0127__en-us_topic_0093946957_table7064698105347">Table 2</a>. JDBC configuration items can be separated by semicolons (;) in the URL, or you can dynamically set the attribute items using the Info object. For details, see <a href="#dli_09_0127__en-us_topic_0093946957_table31567601152339">Table 3</a>.
<div class="tablenoborder"><a name="dli_09_0127__en-us_topic_0093946957_table7064698105347"></a><a name="en-us_topic_0093946957_table7064698105347"></a><table cellpadding="4" cellspacing="0" summary="" id="dli_09_0127__en-us_topic_0093946957_table7064698105347" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Database connection parameters</caption><thead align="left"><tr id="dli_09_0127__en-us_topic_0093946957_row65073311105347"><th align="left" class="cellrowborder" valign="top" width="12.23%" id="mcps1.3.3.2.6.2.2.3.2.3.1.1"><p id="dli_09_0127__en-us_topic_0093946957_p59586123105347">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="87.77000000000001%" id="mcps1.3.3.2.6.2.2.3.2.3.1.2"><p id="dli_09_0127__en-us_topic_0093946957_p61746676105347">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_09_0127__en-us_topic_0093946957_row18849173105347"><td class="cellrowborder" valign="top" width="12.23%" headers="mcps1.3.3.2.6.2.2.3.2.3.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p50388005105347">url</p>
</td>
<td class="cellrowborder" valign="top" width="87.77000000000001%" headers="mcps1.3.3.2.6.2.2.3.2.3.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p54896577105347">The URL format is as follows:</p>
<p id="dli_09_0127__en-us_topic_0093946957_p59619235143640">jdbc:dli://&lt;endPoint&gt;/projectId? &lt;key1&gt;=&lt;val1&gt;;&lt;key2&gt;=&lt;val2&gt;...</p>
<ul id="dli_09_0127__en-us_topic_0093946957_ul079115391211"><li id="dli_09_0127__li16595184242912"><strong id="dli_09_0127__b84235270617440">EndPoint</strong> indicates the DLI domain name. <strong id="dli_09_0127__b1258950172114">ProjectId</strong> indicates the project ID.<p id="dli_09_0127__p192174772918">To obtain the endpoint corresponding to DLI, contact the administrator to obtain the region and endpoint information. To obtain the project ID, log in to the cloud, move the mouse on the account, and click <strong id="dli_09_0127__b015911570212">My Credentials</strong> from the shortcut menu.</p>
</li><li id="dli_09_0127__en-us_topic_0093946957_li7806133910215">Other configuration items are listed after <span class="parmname" id="dli_09_0127__parmname487250005174445"><b>?</b></span> in the form of <span class="parmname" id="dli_09_0127__parmname1606836144174445"><b>key=value</b></span>. The configuration items are separated by semicolons (<span class="parmname" id="dli_09_0127__parmname2061485659174445"><b>;</b></span>). They can also be passed using the Info object.</li></ul>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row24307152105347"><td class="cellrowborder" valign="top" width="12.23%" headers="mcps1.3.3.2.6.2.2.3.2.3.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p22722282105347">Info</p>
</td>
<td class="cellrowborder" valign="top" width="87.77000000000001%" headers="mcps1.3.3.2.6.2.2.3.2.3.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p54391264144914">The Info object passes user-defined configuration items. If Info does not pass any attribute item, you can set it to null. The format is as follows: info.setProperty ("Attribute item", "Attribute value").</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="tablenoborder"><a name="dli_09_0127__en-us_topic_0093946957_table31567601152339"></a><a name="en-us_topic_0093946957_table31567601152339"></a><table cellpadding="4" cellspacing="0" summary="" id="dli_09_0127__en-us_topic_0093946957_table31567601152339" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Attribute items</caption><thead align="left"><tr id="dli_09_0127__en-us_topic_0093946957_row36532279152339"><th align="left" class="cellrowborder" valign="top" width="20.58585858585859%" id="mcps1.3.3.2.6.2.2.4.2.5.1.1"><p id="dli_09_0127__en-us_topic_0093946957_p27119155155349">Item</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="19.13131313131313%" id="mcps1.3.3.2.6.2.2.4.2.5.1.2"><p id="dli_09_0127__en-us_topic_0093946957_p49167942155349">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="11.616161616161618%" id="mcps1.3.3.2.6.2.2.4.2.5.1.3"><p id="dli_09_0127__en-us_topic_0093946957_p23180374155349">Default Value</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="48.66666666666667%" id="mcps1.3.3.2.6.2.2.4.2.5.1.4"><p id="dli_09_0127__en-us_topic_0093946957_p65670986155349">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_09_0127__en-us_topic_0093946957_row30320199152339"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p26912549155542">queuename</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p32432850155542">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p9815175155542">-</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p56831725155542">Queue name of DLI.</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row63719185152339"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p24158859155542">databasename</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p10710594155542">No</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p62251748155542">-</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p9226843155542">Name of a database.</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row36990844152339"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p15482763155542">authenticationmode</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p46144292155542">No</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p46700206155542">token</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p24620369155542">Authentication mode. Currently, token- and AK/SK-based authentication modes are supported.</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row49918453152339"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p30182485155542">accesskey</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p28862203155542">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p56137143155542">-</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p50814702155542">AK/SK authentication key. For details about how to obtain the key, see <a href="dli_09_0126.html">Performing Authentication</a>.</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row42867189152339"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p66934242155542">secretkey</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p52964496155542">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p62265750155542">-</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p10360989155542">AK/SK authentication key. For details about how to obtain the key, see <a href="dli_09_0126.html">Performing Authentication</a>.</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row45735434152339"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p8700049155542">servicename</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p33615355155542">This parameter must be configured if <strong id="dli_09_0127__b531634015">authenticationmode</strong> is set to <strong id="dli_09_0127__b461458486">aksk</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p38489254155542">-</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p30621882155542">Indicates the service name, that is, <strong id="dli_09_0127__b17736219391">dli</strong>.</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row13967320155445"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p43209165155542">token</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p10281485155542">This parameter must be configured if <strong id="dli_09_0127__b514132531">authenticationmode</strong> is set to <strong id="dli_09_0127__b1325801282">token</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p27493937155542">-</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p12416418155542">Token authentication. For details about the authentication mode, see <a href="dli_09_0126.html">Performing Authentication</a>.</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row53630162155451"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p58980992155542">charset</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p12731087155542">No</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p24585159155542">UTF-8</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p45240847155542">JDBC encoding mode.</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row37026246155458"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p30125388155542">usehttpproxy</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p24237364155542">No</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p17069481155542">false</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p40450706155542">Whether to use the access proxy.</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row2933267015554"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p27773721155542">proxyhost</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p35078900155542">This parameter must be configured if <strong id="dli_09_0127__b835075023">usehttpproxy</strong> is set to <strong id="dli_09_0127__b671610282">true</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p22818656155542">-</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p36371844155542">Access proxy host.</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row46965394155514"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p7073623155542">proxyport</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p36092624155542">This parameter must be configured if <strong id="dli_09_0127__b305012803">usehttpproxy</strong> is set to <strong id="dli_09_0127__b726010775">true</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p37821437155542">-</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p43637575155542">Access proxy port.</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row137821327122215"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p17881427172216">dli.sql.checkNoResultQuery</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p17788142792217">No</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p87882027132219">false</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p9148172623514">Whether to allow invoking the executeQuery API to execute statements (for example, DDL) that do not return results.</p>
<ul id="dli_09_0127__en-us_topic_0093946957_ul564813417352"><li id="dli_09_0127__en-us_topic_0093946957_li3648741193513">Value <strong id="dli_09_0127__b84235270611428">false</strong> indicates that invoking of the executeQuery API is allowed.</li><li id="dli_09_0127__en-us_topic_0093946957_li1864844113354">Value <strong id="dli_09_0127__b84235270611440">true</strong> indicates that invoking of the executeQuery API is not allowed.</li></ul>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row13949192314125"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p18950132351218">jobtimeout</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p595032371216">No</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p995072311210">300</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p89501323171218">End time of the job submission. Unit: second</p>
</td>
</tr>
<tr id="dli_09_0127__row544684419017"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__p64461644706">iam.endpoint</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__p114464441006">No. By default, the value is automatically combined based on <strong id="dli_09_0127__b3742111484613">regionName</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__p94461444208">-</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__p673495714588">-</p>
</td>
</tr>
<tr id="dli_09_0127__row163218196213"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__p83214191023">obs.endpoint</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__p2158172814212">No. By default, the value is automatically combined based on <strong id="dli_09_0127__b81281025134610">regionName</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__p7158528827">-</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__p09985488115">-</p>
</td>
</tr>
<tr id="dli_09_0127__row118362462526"><td class="cellrowborder" valign="top" width="20.58585858585859%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.1 "><p id="dli_09_0127__p5836124695219">directfetchthreshold</p>
</td>
<td class="cellrowborder" valign="top" width="19.13131313131313%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.2 "><p id="dli_09_0127__p1783714615522">No</p>
</td>
<td class="cellrowborder" valign="top" width="11.616161616161618%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.3 "><p id="dli_09_0127__p78371146135217">1000</p>
</td>
<td class="cellrowborder" valign="top" width="48.66666666666667%" headers="mcps1.3.3.2.6.2.2.4.2.5.1.4 "><p id="dli_09_0127__p1081519471391">Check whether the number of returned results exceeds the threshold based on service requirements.</p>
<p id="dli_09_0127__p10136635403">The default threshold is <strong id="dli_09_0127__b95006161126">1000</strong>.</p>
<p id="dli_09_0127__p636664074016">If the number of query results to be obtained is less than or equal to the preset value, you can call the getJobResult function to obtain the results.</p>
<p id="dli_09_0127__p9837194615522">If the number of query results are greater than the preset value, you need to manually export the query results.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</p></li><li id="dli_09_0127__en-us_topic_0093946957_li14728875103424"><span>Create a Statement object, set related parameters, and submit Spark SQL to DLI.</span><p><p id="dli_09_0127__en-us_topic_0093946957_p6318330155737"><b><span class="cmdname" id="dli_09_0127__en-us_topic_0093946957_cmdname8623163915010">Statement statement = conn.createStatement();</span></b></p>
<p id="dli_09_0127__p191786471502">statement.execute("SET dli.sql.spark.sql.forcePartitionPredicatesOnPartitionedTable.enabled=true");</p>
<p id="dli_09_0127__en-us_topic_0093946957_p56864971155737"><b><span class="cmdname" id="dli_09_0127__en-us_topic_0093946957_cmdname138211471015">statement.execute("select * from tb1");</span></b></p>
</p></li><li id="dli_09_0127__en-us_topic_0093946957_li5740346216931"><span>Obtain the result.</span><p><p id="dli_09_0127__en-us_topic_0093946957_p17906742151311"><b><span class="cmdname" id="dli_09_0127__en-us_topic_0093946957_cmdname1534711918">ResultSet rs = statement.getResultSet();</span></b></p>
</p></li><li id="dli_09_0127__en-us_topic_0093946957_li13900091151418"><span>Display the result.</span><p><pre class="screen" id="dli_09_0127__en-us_topic_0093946957_screen20944234151543">while (rs.next()) {
int a = rs.getInt(1);
int b = rs.getInt(2);
}</pre>
</p></li><li id="dli_09_0127__en-us_topic_0093946957_li39202667175346"><span>Close the connection.</span><p><p id="dli_09_0127__en-us_topic_0093946957_p5618479516118"><b><span class="cmdname" id="dli_09_0127__en-us_topic_0093946957_cmdname67242151512">conn.close();</span></b></p>
</p></li></ol>
</div>
<div class="section" id="dli_09_0127__en-us_topic_0093946957_section4858632153443"><h4 class="sectiontitle">Example</h4><div class="note" id="dli_09_0127__note84662050195919"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dli_09_0127__p1140569541">Hard-coded or plaintext AK and SK pose significant security risks. To ensure security, encrypt your AK and SK, store them in configuration files or environment variables, and decrypt them when needed.</p>
</div></div>
<pre class="screen" id="dli_09_0127__en-us_topic_0093946957_screen5453761691759">import java.sql.*;
import java.util.Properties;
public class DLIJdbcDriverExample {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Connection conn = null;
try {
Class.forName("com.dli.jdbc.DliDriver");
String url = "jdbc:dli://&lt;endpoint&gt;/&lt;projectId&gt;?databasename=db1;queuename=testqueue";
Properties info = new Properties();
info.setProperty("authenticationmode", "aksk");
info.setProperty("regionname", "&lt;real region name&gt;");
info.setProperty("accesskey", "&lt;real ak&gt;");
info.setProperty("secretkey", "&lt;real sk&gt;")
conn = DriverManager.getConnection(url, info);
Statement statement = conn.createStatement();
statement.execute("select * from tb1");
ResultSet rs = statement.getResultSet();
int line = 0;
while (rs.next()) {
line ++;
int a = rs.getInt(1);
int b = rs.getInt(2);
System.out.println("Line:" + line + ":" + a + "," + b);
}
statement.execute("SET dli.sql.spark.sql.forcePartitionPredicatesOnPartitionedTable.enabled=true");
statement.execute("describe tb1");
ResultSet rs1 = statement.getResultSet();
line = 0;
while (rs1.next()) {
line ++;
String a = rs1.getString(1);
String b = rs1.getString(2);
System.out.println("Line:" + line + ":" + a + "," + b);
}
} catch (SQLException ex) {
} finally {
if (conn != null) {
conn.close();
}
}
}
}</pre>
</div>
<div class="section" id="dli_09_0127__en-us_topic_0093946957_section15651195375719"><h4 class="sectiontitle">Enabling JDBC Requery</h4><p id="dli_09_0127__en-us_topic_0093946957_p18538176195815">If the JDBC requery function is enabled, the system automatically requeries when the query operation fails.</p>
<div class="note" id="dli_09_0127__en-us_topic_0093946957_note1946995213614"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="dli_09_0127__en-us_topic_0093946957_ul1415043414913"><li id="dli_09_0127__en-us_topic_0093946957_li201501341292">To avoid repeated data insertion, non-query statements do not support requery.</li><li id="dli_09_0127__en-us_topic_0093946957_li1715113346913">This function is available in the JDBC driver package of 1.1.5 or later. To use this function, obtain the latest JDBC driver package.</li></ul>
</div></div>
<p id="dli_09_0127__en-us_topic_0093946957_p1811212578108">To enable the requery function, add the attributes listed in <a href="#dli_09_0127__en-us_topic_0093946957_table127918458100">Table 4</a> to the <strong id="dli_09_0127__b442117161328">Info</strong> parameter.</p>
<div class="tablenoborder"><a name="dli_09_0127__en-us_topic_0093946957_table127918458100"></a><a name="en-us_topic_0093946957_table127918458100"></a><table cellpadding="4" cellspacing="0" summary="" id="dli_09_0127__en-us_topic_0093946957_table127918458100" frame="border" border="1" rules="all"><caption><b>Table 4 </b>Requery parameter description</caption><thead align="left"><tr id="dli_09_0127__en-us_topic_0093946957_row14791174519105"><th align="left" class="cellrowborder" valign="top" width="22.222222222222225%" id="mcps1.3.5.5.2.5.1.1"><p id="dli_09_0127__en-us_topic_0093946957_p379117453106">Item</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="11.404040404040403%" id="mcps1.3.5.5.2.5.1.2"><p id="dli_09_0127__en-us_topic_0093946957_p1679234591020">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="11.171717171717173%" id="mcps1.3.5.5.2.5.1.3"><p id="dli_09_0127__en-us_topic_0093946957_p57929456101">Default Value</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="55.20202020202019%" id="mcps1.3.5.5.2.5.1.4"><p id="dli_09_0127__en-us_topic_0093946957_p179254512108">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_09_0127__en-us_topic_0093946957_row16792184521016"><td class="cellrowborder" valign="top" width="22.222222222222225%" headers="mcps1.3.5.5.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p8504135612130">USE_RETRY_KEY</p>
</td>
<td class="cellrowborder" valign="top" width="11.404040404040403%" headers="mcps1.3.5.5.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p15792745161018">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="11.171717171717173%" headers="mcps1.3.5.5.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p127921045151018">false</p>
</td>
<td class="cellrowborder" valign="top" width="55.20202020202019%" headers="mcps1.3.5.5.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p460991216143">Whether to enable the requery function. If this parameter is set to <strong id="dli_09_0127__b14377131119331">True</strong>, the requery function is enabled.</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row197923450104"><td class="cellrowborder" valign="top" width="22.222222222222225%" headers="mcps1.3.5.5.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p450418568133">RETRY_TIMES_KEY</p>
</td>
<td class="cellrowborder" valign="top" width="11.404040404040403%" headers="mcps1.3.5.5.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p5792645111010">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="11.171717171717173%" headers="mcps1.3.5.5.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p1579234517108">3000</p>
</td>
<td class="cellrowborder" valign="top" width="55.20202020202019%" headers="mcps1.3.5.5.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p261091212141">Requery interval (milliseconds). Set this parameter to <strong id="dli_09_0127__b13914156134613">30000</strong> ms.</p>
</td>
</tr>
<tr id="dli_09_0127__en-us_topic_0093946957_row1793194531011"><td class="cellrowborder" valign="top" width="22.222222222222225%" headers="mcps1.3.5.5.2.5.1.1 "><p id="dli_09_0127__en-us_topic_0093946957_p185051956181319">RETRY_INTERVALS_KEY</p>
</td>
<td class="cellrowborder" valign="top" width="11.404040404040403%" headers="mcps1.3.5.5.2.5.1.2 "><p id="dli_09_0127__en-us_topic_0093946957_p579354514106">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="11.171717171717173%" headers="mcps1.3.5.5.2.5.1.3 "><p id="dli_09_0127__en-us_topic_0093946957_p8793445101013">3</p>
</td>
<td class="cellrowborder" valign="top" width="55.20202020202019%" headers="mcps1.3.5.5.2.5.1.4 "><p id="dli_09_0127__en-us_topic_0093946957_p17610412181413">Requery times. Set this parameter to a value from 3 to 5.</p>
</td>
</tr>
</tbody>
</table>
</div>
<p id="dli_09_0127__en-us_topic_0093946957_p726113621910">Set JDBC parameters, enable the requery function, and create a link. The following is an example:</p>
<pre class="screen" id="dli_09_0127__en-us_topic_0093946957_screen2302183015429">import com.<em id="dli_09_0127__i15272183619584">xxx</em>.dli.jdbs.utils.ConnectionResource;// Introduce "ConnectionResource". Change the class name as needed.
import java.sql.*;
import java.util.Properties;
public class DLIJdbcDriverExample {
private static final String X_AUTH_TOKEN_VALUE = "&lt;realtoken&gt;";
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Connection conn = null;
try {
Class.forName("com.dli.jdbc.DliDriver");
String url = "jdbc:dli://&lt;endpoint&gt;/&lt;projectId&gt;?databasename=db1;queuename=testqueue";
Properties info = new Properties();
info.setProperty("token", X_AUTH_TOKEN_VALUE);
<strong id="dli_09_0127__b7350161817354">info.setProperty(ConnectionResource.USE_RETRY_KEY, "true"); // Enable the requery function.</strong>
<strong id="dli_09_0127__b1191913275353">info.setProperty(ConnectionResource.RETRY_TIMES_KEY, "30000");// Requery interval (ms)</strong>
<strong id="dli_09_0127__b281011374357">info.setProperty(ConnectionResource.RETRY_INTERVALS_KEY, "5");// Requery Times</strong>
conn = DriverManager.getConnection(url, info);
Statement statement = conn.createStatement();
statement.execute("select * from tb1");
ResultSet rs = statement.getResultSet();
int line = 0;
while (rs.next()) {
line ++;
int a = rs.getInt(1);
int b = rs.getInt(2);
System.out.println("Line:" + line + ":" + a + "," + b);
}
statement.execute("describe tb1");
ResultSet rs1 = statement.getResultSet();
line = 0;
while (rs1.next()) {
line ++;
String a = rs1.getString(1);
String b = rs1.getString(2);
System.out.println("Line:" + line + ":" + a + "," + b);
}
} catch (SQLException ex) {
} finally {
if (conn != null) {
conn.close();
}
}
}
}</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_09_0123.html">Submitting a Spark SQL Job Using JDBC</a></div>
</div>
</div>