doc-exports/docs/dws/dev/dws_04_0093.html
Lu, Huayi a24ca60074 DWS DEVELOPER 811 version
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2023-01-19 13:37:49 +00:00

139 lines
23 KiB
HTML

<a name="EN-US_TOPIC_0000001099134844"></a><a name="EN-US_TOPIC_0000001099134844"></a>
<h1 class="topictitle1">Connecting to a Database</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001099134844__en-us_topic_0059779354_p948818398417">After a database is connected, you can execute SQL statements in the database.</p>
<div class="note" id="EN-US_TOPIC_0000001099134844__note19342720153419"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001099134844__p2065920386471">If you use an open-source Java Database Connectivity (JDBC) driver, ensure that the database parameter <strong id="EN-US_TOPIC_0000001099134844__b19894113153316">password_encryption_type</strong> is set to <strong id="EN-US_TOPIC_0000001099134844__b3746203323314">1</strong>. If the value is not 1, the connection may fail. A typical error message is "none of the server's SASL authentication mechanisms are supported." To avoid such problems, perform the following operations:</p>
<ol id="EN-US_TOPIC_0000001099134844__ol1867461614519"><li id="EN-US_TOPIC_0000001099134844__li18674101613513">Set <strong id="EN-US_TOPIC_0000001099134844__b0287540315">password_encryption_type</strong> to <strong id="EN-US_TOPIC_0000001099134844__b128764103114">1</strong>. For details, see "Modifying Database Parameters" in <em id="EN-US_TOPIC_0000001099134844__i162877415317">User Guide</em>.</li><li id="EN-US_TOPIC_0000001099134844__li8674191619518">Create a new database user for connection or reset the password of the existing database user.<ul id="EN-US_TOPIC_0000001099134844__ul136741416145115"><li id="EN-US_TOPIC_0000001099134844__li867431618515">If you use an administrator account, reset the password. For details, see "Password Reset" in <em id="EN-US_TOPIC_0000001099134844__i519563620402">User Guide</em>.</li><li id="EN-US_TOPIC_0000001099134844__li1745295113575">If you are a common user, use another client tool (such as Data Studio) to connect to the database and run the <strong id="EN-US_TOPIC_0000001099134844__b16330145103915">ALTER USER</strong> statement to change your password.</li></ul>
</li><li id="EN-US_TOPIC_0000001099134844__li176328710583">Connect to the database.</li></ol>
<p id="EN-US_TOPIC_0000001099134844__p24118503415"></p>
<p id="EN-US_TOPIC_0000001099134844__p20733151055215">Here are the reasons why you need to perform these operations:</p>
<ul id="EN-US_TOPIC_0000001099134844__ul9472201514422"><li id="EN-US_TOPIC_0000001099134844__li5472715124217">MD5 algorithms may by vulnerable to collision attacks and cannot be used for password verification. Currently, GaussDB(DWS) uses the default security design. By default, MD5 password verification is disabled, but MD5 is required by the open-source libpq communication protocol of PostgreSQL. For connectivity purposes, you need to adjust the cryptographic algorithm parameter <strong id="EN-US_TOPIC_0000001099134844__b1730912544373">password_encryption_type</strong> and enable the MD5 algorithm.</li><li id="EN-US_TOPIC_0000001099134844__li1847220158427">The database stores the hash digest of passwords instead of password text. During password verification, the system compares the hash digest with the password digest sent from the client (salt operations are involved). If you change your cryptographic algorithm policy, the database cannot generate a new MD5 hash digest for your existing password. For connectivity purposes, you must manually change your password or create a new user. The new password will be encrypted using the hash algorithm and stored for authentication in the next connection.</li></ul>
</div></div>
<div class="section" id="EN-US_TOPIC_0000001099134844__s57807bb88f8443d89adad8e3f8ee5264"><h4 class="sectiontitle">Function Prototype</h4><p id="EN-US_TOPIC_0000001099134844__a1290a21c3f4a42fe8ed5b87a7fa27bea">JDBC provides the following three database connection methods:</p>
<ul id="EN-US_TOPIC_0000001099134844__u88b2b87027a6476e83080b599bf37529"><li id="EN-US_TOPIC_0000001099134844__le6dca7e0a8ef4394a6e497986423f777">DriverManager.getConnection(String url);</li><li id="EN-US_TOPIC_0000001099134844__l20aec76f8c1043558cd368166daa9aa6">DriverManager.getConnection(String url, Properties info);</li><li id="EN-US_TOPIC_0000001099134844__l6efd1f62c2ae49bcbb0e6bd6e1768aeb">DriverManager.getConnection(String url, String user, String password);</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001099134844__s3f963f87690b40dc8d480e5acca94eb4"><h4 class="sectiontitle">Parameter</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001099134844__t6e91fcf016964232ae79f17e8160e7ce" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Database connection parameters</caption><thead align="left"><tr id="EN-US_TOPIC_0000001099134844__r51e724f205e64ddc99f18495764e935a"><th align="left" class="cellrowborder" valign="top" width="13%" id="mcps1.3.4.2.2.3.1.1"><p id="EN-US_TOPIC_0000001099134844__aef564c8a17fd44b799850596b376c501">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="87%" id="mcps1.3.4.2.2.3.1.2"><p id="EN-US_TOPIC_0000001099134844__a45a65a35a7374832ad0b76f1590eae48">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001099134844__r93dfa37ce5944dedba6aa61c568a1f91"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001099134844__add7cddadf9d44578925be52df2dfe367">url</p>
</td>
<td class="cellrowborder" valign="top" width="87%" headers="mcps1.3.4.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001099134844__a1cf0afcb331646d887bdf79d72ad4b88"><strong id="EN-US_TOPIC_0000001099134844__b16015422218">gsjdbc4.jar</strong> database connection descriptor. The descriptor format can be:</p>
<ul id="EN-US_TOPIC_0000001099134844__ude90174d20344cc1aa2bffac0ce922db"><li id="EN-US_TOPIC_0000001099134844__l9de386d881f2401da4ee43320fb31dc7">jdbc:postgresql:database</li><li id="EN-US_TOPIC_0000001099134844__l73b378cf34d34098a3c3f7f7a428a0f0">jdbc:postgresql://host/database</li><li id="EN-US_TOPIC_0000001099134844__l2d519f1cef1a4e90b2c85191716f6980">jdbc:postgresql://host:port/database</li><li id="EN-US_TOPIC_0000001099134844__li139771853413">jdbc:postgresql://host:port[,host:port][...]/database</li></ul>
<div class="note" id="EN-US_TOPIC_0000001099134844__n16fc25d92c244d68817e6df6d768bbc9"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="EN-US_TOPIC_0000001099134844__p1069826216120">If <strong id="EN-US_TOPIC_0000001099134844__b13149538225">gsjdbc200.jar</strong> is used, replace <strong id="EN-US_TOPIC_0000001099134844__b3755717230">jdbc:postgresql</strong> with <strong id="EN-US_TOPIC_0000001099134844__b118051110234">jdbc:gaussdb</strong>.</p>
<ul id="EN-US_TOPIC_0000001099134844__ue24edf2cc0a9448495fbf4a286ba0e10"><li id="EN-US_TOPIC_0000001099134844__l817d6a9711c24629bb836d2812711c69"><strong id="EN-US_TOPIC_0000001099134844__b84235270610641">database</strong>: indicates the name of the database to be connected.</li><li id="EN-US_TOPIC_0000001099134844__lcdc7dc18e83e43d08a39fac766e1f87c"><strong id="EN-US_TOPIC_0000001099134844__b93879364443">host</strong>: indicates the name or IP address of the database server.<p id="EN-US_TOPIC_0000001099134844__en-us_topic_0059779354_p461072082618">Specify the IP address for connecting to the <span id="EN-US_TOPIC_0000001099134844__text1664272195518">GaussDB(DWS)</span> cluster on <span id="EN-US_TOPIC_0000001099134844__text881055218512">GaussDB(DWS)</span> management console. If the connected host and the <span id="EN-US_TOPIC_0000001099134844__text7425515125211">GaussDB(DWS)</span> cluster are in the same network, select the private IP address. Otherwise, select the public IP address.</p>
<p id="EN-US_TOPIC_0000001099134844__p1441610315219">For security purposes, the CN forbids access from other nodes in the cluster without authentication. To access the CN from inside the cluster, deploy the JDBC program on the host where the CN is located and set <strong id="EN-US_TOPIC_0000001099134844__b4127181518014">host</strong> to <strong id="EN-US_TOPIC_0000001099134844__b157902191903">127.0.0.1</strong>. Otherwise, the error message <strong id="EN-US_TOPIC_0000001099134844__b5557154416393">FATAL: Forbid remote connection with trust method!</strong> may be displayed.</p>
<p id="EN-US_TOPIC_0000001099134844__p572510297236">It is recommended that the service system be deployed outside the cluster. Otherwise, the database performance may be affected.</p>
</li><li id="EN-US_TOPIC_0000001099134844__lb7a87e31c5f84c8b98d83b732a43f16e"><strong id="EN-US_TOPIC_0000001099134844__b81921558103110">port</strong>: indicates the port number of a database server. By default, the database on port <strong id="EN-US_TOPIC_0000001099134844__b10941163641812"><span id="EN-US_TOPIC_0000001099134844__text1768017568445">8000</span></strong> of the local host is connected.</li><li id="EN-US_TOPIC_0000001099134844__li1881420322246">Multiple IP addresses and ports can be configured. JDBC balances load by random access and failover, and will automatically ignore unreachable IP addresses.<p id="EN-US_TOPIC_0000001099134844__p8590193320245"><a name="EN-US_TOPIC_0000001099134844__li1881420322246"></a><a name="li1881420322246"></a>IP addresses are separated using commas. Example: <strong id="EN-US_TOPIC_0000001099134844__b14570888849957">jdbc:postgresql://10.10.0.13:<span id="EN-US_TOPIC_0000001099134844__text1862833875917">8000</span>,10.10.0.14:<span id="EN-US_TOPIC_0000001099134844__text191961546205919">8000</span>/database</strong></p>
</li></ul>
</div></div>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001099134844__re8422e921f2545ef81f269251b095386"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001099134844__a4cc9c4f2d6ad4a438da6b4be4a0bbb49">info</p>
</td>
<td class="cellrowborder" valign="top" width="87%" headers="mcps1.3.4.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001099134844__a3fac73fcef9f445e90ab567819781679">Database connection properties. Common properties include:</p>
<ul id="EN-US_TOPIC_0000001099134844__ue7508e5a1b3a4615a5eff8dc9eac753a"><li id="EN-US_TOPIC_0000001099134844__l95f308a3ce844132917dd5e8cb23952a"><strong id="EN-US_TOPIC_0000001099134844__b2861061114423">user</strong>: string type. It indicates the database user who creates the connection.</li><li id="EN-US_TOPIC_0000001099134844__lda3b1ec2df6a4266883da278e93624d6"><strong id="EN-US_TOPIC_0000001099134844__b6391245314423">password</strong>: string type. It indicates the password of a database user.</li><li id="EN-US_TOPIC_0000001099134844__lc5eb481b22754604b1c4d476f1c2a7bd"><strong id="EN-US_TOPIC_0000001099134844__b2319919214423">ssl</strong>: boolean type. It indicates whether the Secure Socket Layer (SSL) is used.</li><li id="EN-US_TOPIC_0000001099134844__li87792117464"><strong id="EN-US_TOPIC_0000001099134844__b923522303920">loggerLevel</strong>: string type. It indicates the amount of information that the driver logs and prints to the LogStream or LogWriter specified in the DriverManager. Currently, <strong id="EN-US_TOPIC_0000001099134844__b8456181454015">OFF</strong>, <strong id="EN-US_TOPIC_0000001099134844__b173895164401">DEBUG</strong>, and <strong id="EN-US_TOPIC_0000001099134844__b105641319204016">TRACE</strong> are supported. <strong id="EN-US_TOPIC_0000001099134844__b880513515404">DEBUG</strong> indicates that only logs of the <strong id="EN-US_TOPIC_0000001099134844__b284119512400">DEBUG</strong> or higher level are printed, generating little log information. <strong id="EN-US_TOPIC_0000001099134844__b479283415413">TRACE</strong> indicates that logs of the <strong id="EN-US_TOPIC_0000001099134844__b6739542423">DEBUG</strong> and <strong id="EN-US_TOPIC_0000001099134844__b8415168154219">TRACE</strong> levels are printed, generating detailed log information. The default value is <strong id="EN-US_TOPIC_0000001099134844__b9451161111447">OFF</strong>, indicating that no information will be logged.</li><li id="EN-US_TOPIC_0000001099134844__lc810077008fa4d9798ae733ee402cccf"><strong id="EN-US_TOPIC_0000001099134844__b3452109514423">prepareThreshold</strong>: integer type. It indicates the number of <strong id="EN-US_TOPIC_0000001099134844__b5430114423">PreparedStatement</strong> executions required before requests are converted to prepared statements in servers. The default value is <strong id="EN-US_TOPIC_0000001099134844__b842352706101416">5</strong>.</li><li id="EN-US_TOPIC_0000001099134844__li62157221239"><strong id="EN-US_TOPIC_0000001099134844__b16976118111310">batchMode</strong>: boolean type. It indicates whether to connect the database in batch mode.</li><li id="EN-US_TOPIC_0000001099134844__li198011645489"><strong id="EN-US_TOPIC_0000001099134844__b16844342121812">fetchsize</strong>: integer type. It indicates the default fetch size for statements in the created connection.</li><li id="EN-US_TOPIC_0000001099134844__li1580508012022"><strong id="EN-US_TOPIC_0000001099134844__b1871763815910">ApplicationName</strong>: string type. It indicates an application name. The default value is <strong id="EN-US_TOPIC_0000001099134844__b1840414470017">PostgreSQL JDBC Driver</strong>.</li><li id="EN-US_TOPIC_0000001099134844__li20991068101733"><strong id="EN-US_TOPIC_0000001099134844__b2597248141315">allowReadOnly</strong>: boolean type. It indicates whether to enable the read-only mode for connection. The default value is <strong id="EN-US_TOPIC_0000001099134844__b1360319489131">false</strong>. If the value is not changed to <strong id="EN-US_TOPIC_0000001099134844__b176039484135">true</strong>, the execution of <strong id="EN-US_TOPIC_0000001099134844__b106031448141316">connection.setReadOnly</strong> does not take effect.</li><li id="EN-US_TOPIC_0000001099134844__li58920766163137"><strong id="EN-US_TOPIC_0000001099134844__b121531640883">blobMode</strong>: string type. It is used to set the setBinaryStream method to assign values to different data types. The value <strong id="EN-US_TOPIC_0000001099134844__b2062210518193">on</strong> indicates that values are assigned to the BLOB data type and <strong id="EN-US_TOPIC_0000001099134844__b1840811184209">off</strong> indicates that values are assigned to the BYTEA data type. The default value is <strong id="EN-US_TOPIC_0000001099134844__b149051051202012">on</strong>.</li><li id="EN-US_TOPIC_0000001099134844__li14943122819372"><strong id="EN-US_TOPIC_0000001099134844__b432619279322">connectionExtraInfo</strong>: boolean type. It indicates whether the JDBC driver reports the driver deployment path and process owner to the database.<div class="note" id="EN-US_TOPIC_0000001099134844__note177665024418"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="EN-US_TOPIC_0000001099134844__p197674018449">The value can be <strong id="EN-US_TOPIC_0000001099134844__b1286716280522">true</strong> or <strong id="EN-US_TOPIC_0000001099134844__b38689287521">false</strong>. The default value is <strong id="EN-US_TOPIC_0000001099134844__b1186818287524">false</strong>. If <strong id="EN-US_TOPIC_0000001099134844__b58331329323">connectionExtraInfo</strong> is set to <strong id="EN-US_TOPIC_0000001099134844__b1483413328329">true</strong>, the JDBC driver reports the driver deployment path and process owner to the database and displays the information in the <strong id="EN-US_TOPIC_0000001099134844__b148341032163210">connection_info</strong> parameter (see <a href="dws_04_0889.html#EN-US_TOPIC_0000001099134530__section4834457114318">connection_info</a>). In this case, you can query the information from <a href="dws_04_0755.html">PG_STAT_ACTIVITY</a> or <a href="dws_04_0820.html">PGXC_STAT_ACTIVITY</a>.</p>
</div></div>
</li></ul>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001099134844__r223c3793463b444e8a1683caf4a924db"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001099134844__abcc03c869ece4e74bcb4076fd9069460">user</p>
</td>
<td class="cellrowborder" valign="top" width="87%" headers="mcps1.3.4.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001099134844__a878f4a74845e43a193e472f0e1793648">Indicates a database user.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001099134844__r1831a5c112ff497cb01f3fd429381fe5"><td class="cellrowborder" valign="top" width="13%" headers="mcps1.3.4.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001099134844__a96330c6820aa4816bc5ec7468a0adb9d">password</p>
</td>
<td class="cellrowborder" valign="top" width="87%" headers="mcps1.3.4.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001099134844__a222b29624efe4ae49abbae1bc5e01e1a">Indicates the password of a database user.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001099134844__s2157acc2f22b412795a8d0d62ab83478"><h4 class="sectiontitle">Examples</h4><div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001099134844__sffed43fecea943d5854883c3e205febc"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span>
<span class="normal">13</span>
<span class="normal">14</span>
<span class="normal">15</span>
<span class="normal">16</span>
<span class="normal">17</span>
<span class="normal">18</span>
<span class="normal">19</span>
<span class="normal">20</span>
<span class="normal">21</span>
<span class="normal">22</span>
<span class="normal">23</span>
<span class="normal">24</span>
<span class="normal">25</span>
<span class="normal">26</span>
<span class="normal">27</span>
<span class="normal">28</span>
<span class="normal">29</span>
<span class="normal">30</span>
<span class="normal">31</span>
<span class="normal">32</span>
<span class="normal">33</span>
<span class="normal">34</span>
<span class="normal">35</span>
<span class="normal">36</span></pre></div></td><td class="code"><div><pre><span></span><span class="c1">//gsjdbc4.jar is used as an example.</span><span class="w"></span>
<span class="c1">//The following code encapsulates database connection operations into an interface. The database can then be connected using an authorized username and password.</span><span class="w"></span>
<span class="kd">public</span><span class="w"> </span><span class="kd">static</span><span class="w"> </span><span class="n">Connection</span><span class="w"> </span><span class="nf">GetConnection</span><span class="p">(</span><span class="n">String</span><span class="w"> </span><span class="n">username</span><span class="p">,</span><span class="w"> </span><span class="n">String</span><span class="w"> </span><span class="n">passwd</span><span class="p">)</span><span class="w"></span>
<span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="c1">//Set the driver class.</span><span class="w"></span>
<span class="w"> </span><span class="n">String</span><span class="w"> </span><span class="n">driver</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;org.postgresql.Driver&quot;</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="c1">//Set the database connection descriptor.</span><span class="w"></span>
<span class="w"> </span><span class="n">String</span><span class="w"> </span><span class="n">sourceURL</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;jdbc:postgresql://10.10.0.13:8000/postgres?currentSchema=test&quot;</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="n">Connection</span><span class="w"> </span><span class="n">conn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">null</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span>
<span class="w"> </span><span class="k">try</span><span class="w"></span>
<span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="c1">//Load the driver.</span><span class="w"></span>
<span class="w"> </span><span class="n">Class</span><span class="p">.</span><span class="na">forName</span><span class="p">(</span><span class="n">driver</span><span class="p">);</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w"> </span><span class="k">catch</span><span class="p">(</span><span class="w"> </span><span class="n">Exception</span><span class="w"> </span><span class="n">e</span><span class="w"> </span><span class="p">)</span><span class="w"></span>
<span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="n">e</span><span class="p">.</span><span class="na">printStackTrace</span><span class="p">();</span><span class="w"></span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">null</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w"> </span>
<span class="w"> </span><span class="k">try</span><span class="w"></span>
<span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="c1">//Create a connection.</span><span class="w"></span>
<span class="w"> </span><span class="n">conn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">DriverManager</span><span class="p">.</span><span class="na">getConnection</span><span class="p">(</span><span class="n">sourceURL</span><span class="p">,</span><span class="w"> </span><span class="n">username</span><span class="p">,</span><span class="w"> </span><span class="n">passwd</span><span class="p">);</span><span class="w"></span>
<span class="w"> </span><span class="n">System</span><span class="p">.</span><span class="na">out</span><span class="p">.</span><span class="na">println</span><span class="p">(</span><span class="s">&quot;Connection succeed!&quot;</span><span class="p">);</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w"> </span><span class="k">catch</span><span class="p">(</span><span class="n">Exception</span><span class="w"> </span><span class="n">e</span><span class="p">)</span><span class="w"></span>
<span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="n">e</span><span class="p">.</span><span class="na">printStackTrace</span><span class="p">();</span><span class="w"></span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">null</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w"> </span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">conn</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="p">};</span><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0088.html">JDBC-Based Development</a></div>
</div>
</div>