doc-exports/docs/dws/dev/dws_04_0509.html
Lu, Huayi e6fa411af0 DWS DEV 830.201 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2024-05-16 07:24:04 +00:00

475 lines
67 KiB
HTML

<a name="EN-US_TOPIC_0000001188482166"></a><a name="EN-US_TOPIC_0000001188482166"></a>
<h1 class="topictitle1">PL/Java Functions</h1>
<div id="body1530499427336"><p id="EN-US_TOPIC_0000001188482166__p8060118">With the <span id="EN-US_TOPIC_0000001188482166__text1664295437">GaussDB(DWS)</span> PL/Java functions, you can choose your favorite Java IDE to write Java methods and install the JAR files containing these methods into the <span id="EN-US_TOPIC_0000001188482166__text449389827">GaussDB(DWS)</span> database before invoking them. <span id="EN-US_TOPIC_0000001188482166__text1654382931">GaussDB(DWS)</span> PL/Java is developed based on open-source PL/Java 1.5.5 and uses JRE 1.8.0_322.</p>
<div class="section" id="EN-US_TOPIC_0000001188482166__section13472159101911"><h4 class="sectiontitle">Constraints</h4><p id="EN-US_TOPIC_0000001188482166__p747212916199">Java UDF can be used for some Java logical computing. You are not advised to encapsulate services in Java UDF.</p>
<ul id="EN-US_TOPIC_0000001188482166__ul347216911918"><li id="EN-US_TOPIC_0000001188482166__li15472159201919">You are not advised to connect to a database in any way (for example, JDBC) in Java functions.</li><li id="EN-US_TOPIC_0000001188482166__li176681919205916">Currently, only data types listed in <a href="#EN-US_TOPIC_0000001188482166__table10200627143416">Table 1</a> are supported. Other data types, such as user-defined data types and complex data types (for example, Java array and its derived types) are not supported.</li><li id="EN-US_TOPIC_0000001188482166__li2472298197">Currently, UDAF and UDTF are not supported.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482166__section114893304543"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001188482166__p439924510259">Before using PL/Java, you need to pack the implementation of Java methods into a JAR package and deploy it into the database. Then, create functions as a database administrator. For compatibility purposes, use JRE 1.8.0_322 for compilation.</p>
<ol id="EN-US_TOPIC_0000001188482166__ol1045715369169"><li id="EN-US_TOPIC_0000001188482166__li84576364168"><a name="EN-US_TOPIC_0000001188482166__li84576364168"></a><a name="li84576364168"></a><span>Compile a JAR package.</span><p><p id="EN-US_TOPIC_0000001188482166__p15993191951717">Java method implementation and JAR package archiving can be achieved in an integrated development environment (IDE). The following is a simple example of compilation and archiving through command lines. You can create a JAR package that contains a single method in the similar way.</p>
<p id="EN-US_TOPIC_0000001188482166__p385201201718">First, prepare an <strong id="EN-US_TOPIC_0000001188482166__b359781215413">Example.java</strong> file that contains a method for converting substrings to uppercase. In the following example, <strong id="EN-US_TOPIC_0000001188482166__b13652171613414">Example</strong> is the class name and <strong id="EN-US_TOPIC_0000001188482166__b11203013413">upperString</strong> is the method name:</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen156231012154417"><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></pre></div></td><td class="code"><div><pre><span></span><span class="kd">public</span><span class="w"> </span><span class="kd">class</span> <span class="nc">Example</span><span class="w"> </span>
<span class="p">{</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">String</span><span class="w"> </span><span class="nf">upperString</span><span class="w"> </span><span class="p">(</span><span class="n">String</span><span class="w"> </span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">beginIndex</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">endIndex</span><span class="p">)</span><span class="w"> </span>
<span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">text</span><span class="p">.</span><span class="na">substring</span><span class="p">(</span><span class="n">beginIndex</span><span class="p">,</span><span class="w"> </span><span class="n">endIndex</span><span class="p">).</span><span class="na">toUpperCase</span><span class="p">();</span>
<span class="w"> </span><span class="p">}</span>
<span class="p">}</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001188482166__p14108115791112">Then, create a <strong id="EN-US_TOPIC_0000001188482166__b1911894173716">manifest.txt</strong> file containing the following content:</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen12863150164419"><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></pre></div></td><td class="code"><div><pre><span></span><span class="n">Manifest</span><span class="o">-</span><span class="n">Version</span><span class="p">:</span><span class="w"> </span><span class="mf">1.0</span>
<span class="n">Main</span><span class="o">-</span><span class="n">Class</span><span class="p">:</span><span class="w"> </span><span class="n">Example</span>
<span class="n">Specification</span><span class="o">-</span><span class="n">Title</span><span class="p">:</span><span class="w"> </span><span class="s">&quot;Example&quot;</span>
<span class="n">Specification</span><span class="o">-</span><span class="n">Version</span><span class="p">:</span><span class="w"> </span><span class="s">&quot;1.0&quot;</span>
<span class="n">Created</span><span class="o">-</span><span class="n">By</span><span class="p">:</span><span class="w"> </span><span class="mf">1.6.0_35</span><span class="o">-</span><span class="n">b10</span><span class="o">-</span><span class="mi">428</span><span class="o">-</span><span class="mi">11</span><span class="n">M3811</span>
<span class="n">Build</span><span class="o">-</span><span class="n">Date</span><span class="p">:</span><span class="w"> </span><span class="mi">08</span><span class="o">/</span><span class="mi">14</span><span class="o">/</span><span class="mi">2018</span><span class="w"> </span><span class="mi">10</span><span class="p">:</span><span class="mi">09</span><span class="w"> </span><span class="n">AM</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001188482166__p1031254344718"><strong id="EN-US_TOPIC_0000001188482166__b7548646181213">Manifest-Version</strong> specifies the version of the <strong id="EN-US_TOPIC_0000001188482166__b19810195931220">manifest</strong> file. <strong id="EN-US_TOPIC_0000001188482166__b865665131316">Main-Class</strong> specifies the main class used by the .jar file. <strong id="EN-US_TOPIC_0000001188482166__b3681849182315">Specification-Title</strong> and <strong id="EN-US_TOPIC_0000001188482166__b04021607243">Specification-Version</strong> are the extended attributes of the package. <strong id="EN-US_TOPIC_0000001188482166__b280171412415">Specification-Title</strong> specifies the title of the extended specification and <strong id="EN-US_TOPIC_0000001188482166__b2684163820240">Specification-Version</strong> specifies the version of the extended specification. <strong id="EN-US_TOPIC_0000001188482166__b1161957132418">Created-By</strong> specifies the person who created the file. <strong id="EN-US_TOPIC_0000001188482166__b10835121313012">Build-Date</strong> specifies the date when the file was created.</p>
<p id="EN-US_TOPIC_0000001188482166__p171396215111">Finally, archive the .java file and package it into <strong id="EN-US_TOPIC_0000001188482166__b1025919177382">javaudf-example.jar</strong>.</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen1928132716459"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">javac</span><span class="w"> </span><span class="n">Example</span><span class="p">.</span><span class="na">java</span>
<span class="n">jar</span><span class="w"> </span><span class="n">cfm</span><span class="w"> </span><span class="n">javaudf</span><span class="o">-</span><span class="n">example</span><span class="p">.</span><span class="na">jar</span><span class="w"> </span><span class="n">manifest</span><span class="p">.</span><span class="na">txt</span><span class="w"> </span><span class="n">Example</span><span class="p">.</span><span class="na">class</span>
</pre></div></td></tr></table></div>
</div>
<div class="notice" id="EN-US_TOPIC_0000001188482166__note2805121310812"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="EN-US_TOPIC_0000001188482166__p158051613886">JAR package names must comply with JDK rules. If a name contains invalid characters, an error occurs when a function is deployed or used.</p>
</div></div>
</p></li><li id="EN-US_TOPIC_0000001188482166__li12780651201619"><span>Deploy the JAR package.</span><p><p id="EN-US_TOPIC_0000001188482166__p16776347798">Place the JAR package on the OBS server using the method described in <span id="EN-US_TOPIC_0000001188482166__ph12241326122712">For details, see "Uploading a File" in <em id="EN-US_TOPIC_0000001188482166__en-us_topic_0121850873_i11596931144017">Object Storage Service Console Operation Guide</em>.</span>. Then, create the AK/SK. For details about how to obtain the AK/SK, see section <a href="dws_04_0183.html">Creating Access Keys (AK and SK)</a>. Log in to the database and run the <strong id="EN-US_TOPIC_0000001188482166__b1779916563403">gs_extend_library</strong> function to import the file to <span id="EN-US_TOPIC_0000001188482166__text96329813">GaussDB(DWS)</span>.</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen1076191584616"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">SELECT</span><span class="w"> </span><span class="nf">gs_extend_library</span><span class="p">(</span><span class="err">'</span><span class="n">addjar</span><span class="err">'</span><span class="p">,</span><span class="w"> </span><span class="err">'</span><span class="n">obs</span><span class="p">:</span><span class="c1">//bucket/path/javaudf-example.jar accesskey=access_key_value_to_be_replaced secretkey=secret_access_key_value_to_be_replaced region=region_name libraryname=example');</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001188482166__p1158292815166">For details about how to use the <strong id="EN-US_TOPIC_0000001188482166__b7407193151618">gs_extend_library</strong> function, see <a href="#EN-US_TOPIC_0000001188482166__li1437422919465">Manage JAR packages and files</a>. Change the values of AK and SK as needed. Replace <em id="EN-US_TOPIC_0000001188482166__i314831165819">region_name</em> with an actual region name.</p>
</p></li><li id="EN-US_TOPIC_0000001188482166__li11306105013139"><span>Use a PL/Java function.</span><p><p id="EN-US_TOPIC_0000001188482166__p1057711294174">Log in to the database as a user who has the <strong id="EN-US_TOPIC_0000001188482166__b89488471356">sysadmin</strong> permission (for example, <span id="EN-US_TOPIC_0000001188482166__text10168144975919">dbadmin</span>) and create the <strong id="EN-US_TOPIC_0000001188482166__b97725843510">java_upperstring</strong> function:</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen46586272479"><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></pre></div></td><td class="code"><div><pre><span></span><span class="n">CREATE</span><span class="w"> </span><span class="n">FUNCTION</span><span class="w"> </span><span class="nf">java_upperstring</span><span class="p">(</span><span class="n">VARCHAR</span><span class="p">,</span><span class="w"> </span><span class="n">INTEGER</span><span class="p">,</span><span class="w"> </span><span class="n">INTEGER</span><span class="p">)</span>
<span class="w"> </span><span class="n">RETURNS</span><span class="w"> </span><span class="n">VARCHAR</span>
<span class="w"> </span><span class="n">AS</span><span class="w"> </span><span class="err">'</span><span class="n">Example</span><span class="p">.</span><span class="na">upperString</span><span class="err">'</span>
<span class="n">LANGUAGE</span><span class="w"> </span><span class="n">JAVA</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<div class="note" id="EN-US_TOPIC_0000001188482166__note3439173616326"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001188482166__ul16402134415326"><li id="EN-US_TOPIC_0000001188482166__li162338081319">The data type defined in the java_upperstring function should be a type in <span id="EN-US_TOPIC_0000001188482166__text872904842">GaussDB(DWS)</span> and match the data type defined in <a href="#EN-US_TOPIC_0000001188482166__li84576364168">1</a> in the upperString method in Java. For details about the mapping between <span id="EN-US_TOPIC_0000001188482166__text1900533305">GaussDB(DWS)</span> and Java data types, see <a href="#EN-US_TOPIC_0000001188482166__table10200627143416">Table 1</a>.</li><li id="EN-US_TOPIC_0000001188482166__li17336213151319">The AS clause specifies the class name and static method name of the Java method invoked by the function. The format is <em id="EN-US_TOPIC_0000001188482166__i44861619164919">Class name</em><strong id="EN-US_TOPIC_0000001188482166__b86500275499">.</strong><em id="EN-US_TOPIC_0000001188482166__i68051223134916">Method name</em>. The class name and method name must match the Java class and method defined in <a href="#EN-US_TOPIC_0000001188482166__li84576364168">1</a>.</li><li id="EN-US_TOPIC_0000001188482166__li152616461027">To use PL/Java functions, set <strong id="EN-US_TOPIC_0000001188482166__b8274153719401">LANGUAGE</strong> to <strong id="EN-US_TOPIC_0000001188482166__b1081094217404">JAVA</strong>.</li><li id="EN-US_TOPIC_0000001188482166__li11709124914015">For details about CREATE FUNCTION, see <a href="#EN-US_TOPIC_0000001188482166__li1541715862915">Create functions</a>.</li></ul>
</div></div>
<p id="EN-US_TOPIC_0000001188482166__p768781221815">Execute the java_upperstring function.</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen9518736174714"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">SELECT</span><span class="w"> </span><span class="nf">java_upperstring</span><span class="p">(</span><span class="err">'</span><span class="n">test</span><span class="err">'</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001188482166__p5578144910186">The expected result is as follows:</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen194381742104710"><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></pre></div></td><td class="code"><div><pre><span></span><span class="w"> </span><span class="n">java_upperstring</span>
<span class="o">---------------------</span>
<span class="w"> </span><span class="n">T</span>
<span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="n">row</span><span class="p">)</span>
</pre></div></td></tr></table></div>
</div>
</p></li><li id="EN-US_TOPIC_0000001188482166__li22171355192013"><span>Authorize a common user to use the PL/Java function.</span><p><p id="EN-US_TOPIC_0000001188482166__p98171632112113">Create a common user named <strong id="EN-US_TOPIC_0000001188482166__b5144102418717">udf_user</strong>.</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen1814151362213"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">CREATE</span><span class="w"> </span><span class="n">USER</span><span class="w"> </span><span class="n">udf_user</span><span class="w"> </span><span class="n">PASSWORD</span><span class="w"> </span><span class="err">'</span><span class="n">password</span><span class="err">'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001188482166__p1433702592216">This command grants user <strong id="EN-US_TOPIC_0000001188482166__b1086621095410">udf_user</strong> the permission for the java_upperstring function. Note that the user can use this function only if it also has the permission for using the schema of the function.</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen2356010143014"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">GRANT</span><span class="w"> </span><span class="n">ALL</span><span class="w"> </span><span class="n">PRIVILEGES</span><span class="w"> </span><span class="n">ON</span><span class="w"> </span><span class="n">SCHEMA</span><span class="w"> </span><span class="kd">public</span><span class="w"> </span><span class="n">TO</span><span class="w"> </span><span class="n">udf_user</span><span class="p">;</span>
<span class="n">GRANT</span><span class="w"> </span><span class="n">ALL</span><span class="w"> </span><span class="n">PRIVILEGES</span><span class="w"> </span><span class="n">ON</span><span class="w"> </span><span class="n">FUNCTION</span><span class="w"> </span><span class="nf">java_upperstring</span><span class="p">(</span><span class="n">VARCHAR</span><span class="p">,</span><span class="w"> </span><span class="n">INTEGER</span><span class="p">,</span><span class="w"> </span><span class="n">INTEGER</span><span class="p">)</span><span class="w"> </span><span class="n">TO</span><span class="w"> </span><span class="n">udf_user</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001188482166__p628973617329">Log in to the database as user <strong id="EN-US_TOPIC_0000001188482166__b1231232884016">udf_user</strong>.</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen1991081183310"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">SET</span><span class="w"> </span><span class="n">SESSION</span><span class="w"> </span><span class="n">SESSION</span><span class="w"> </span><span class="n">AUTHORIZATION</span><span class="w"> </span><span class="n">udf_user</span><span class="w"> </span><span class="n">PASSWORD</span><span class="w"> </span><span class="err">'</span><span class="n">password</span><span class="err">'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001188482166__p6881201819337">Execute the java_upperstring function.</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen11693164573310"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">SELECT</span><span class="w"> </span><span class="kd">public</span><span class="p">.</span><span class="na">java_upperstring</span><span class="p">(</span><span class="err">'</span><span class="n">test</span><span class="err">'</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001188482166__p136996456335">The expected result is as follows:</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen2070144519331"><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></pre></div></td><td class="code"><div><pre><span></span><span class="w"> </span><span class="n">java_upperstring</span>
<span class="o">---------------------</span>
<span class="w"> </span><span class="n">T</span>
<span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="n">row</span><span class="p">)</span>
</pre></div></td></tr></table></div>
</div>
</p></li><li id="EN-US_TOPIC_0000001188482166__li5959164216225"><span>Delete the function.</span><p><div class="p" id="EN-US_TOPIC_0000001188482166__p177703536224">If you no longer need this function, delete it.<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen972114315213"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">DROP</span><span class="w"> </span><span class="n">FUNCTION</span><span class="w"> </span><span class="n">java_upperstring</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
</p></li><li id="EN-US_TOPIC_0000001188482166__li141472412176"><span>Uninstall the JAR package.</span><p><p id="EN-US_TOPIC_0000001188482166__p1915417610415">Use the gs_extend_library function to uninstall the JAR package.</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen676124212487"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">SELECT</span><span class="w"> </span><span class="nf">gs_extend_library</span><span class="p">(</span><span class="err">'</span><span class="n">rmjar</span><span class="err">'</span><span class="p">,</span><span class="w"> </span><span class="err">'</span><span class="n">libraryname</span><span class="o">=</span><span class="n">example</span><span class="err">'</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
</p></li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482166__section1790581992612"><h4 class="sectiontitle">SQL Definition and Usage</h4><ul id="EN-US_TOPIC_0000001188482166__ul94179585291"><li id="EN-US_TOPIC_0000001188482166__li1437422919465"><a name="EN-US_TOPIC_0000001188482166__li1437422919465"></a><a name="li1437422919465"></a><strong id="EN-US_TOPIC_0000001188482166__b16434194674610">Manage JAR packages and files.</strong><p id="EN-US_TOPIC_0000001188482166__p20806174020463">A database user having the <strong id="EN-US_TOPIC_0000001188482166__b1055531241110">sysadmin</strong> permission can use the gs_extend_library function to deploy, view, and delete JAR packages in the database. The syntax of the function is as follows:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188482166__screen880864315315"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">gs_extend_library</span><span class="p">(</span><span class="s1">'[action]'</span><span class="p">,</span><span class="w"> </span><span class="s1">'[operation]'</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<div class="note" id="EN-US_TOPIC_0000001188482166__note1496811305514"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001188482166__ul138514334563"><li id="EN-US_TOPIC_0000001188482166__li72161351201114"><strong id="EN-US_TOPIC_0000001188482166__b15841462">action</strong>: operation action. The options are as follows:<ul id="EN-US_TOPIC_0000001188482166__ul19502056161117"><li id="EN-US_TOPIC_0000001188482166__li68510336569"><strong id="EN-US_TOPIC_0000001188482166__b11551726194614">ls</strong>: Displays JAR packages in the database and checks the MD5 value consistency of files on each node.</li><li id="EN-US_TOPIC_0000001188482166__li198056366567"><strong id="EN-US_TOPIC_0000001188482166__b1045511251366">addjar</strong>: deploys a JAR package on the OBS server in the database.</li><li id="EN-US_TOPIC_0000001188482166__li12351315185716"><strong id="EN-US_TOPIC_0000001188482166__b11642392122">rmjar</strong>: Deletes JAR packages from the database.</li></ul>
</li><li id="EN-US_TOPIC_0000001188482166__li1042010791216"><strong id="EN-US_TOPIC_0000001188482166__b6439112117486">operation</strong>: operation string. The format can be either of the following:<p id="EN-US_TOPIC_0000001188482166__p1743352114514">obs://[bucket]/[source_filepath] accesskey=[accesskey] secretkey=[secretkey] region=[region] libraryname=[libraryname]</p>
<ul id="EN-US_TOPIC_0000001188482166__ul69684311318"><li id="EN-US_TOPIC_0000001188482166__li159681331815"><strong id="EN-US_TOPIC_0000001188482166__b842014131142">bucket</strong>: name of the bucket to which the OBS file belongs. It is mandatory.</li><li id="EN-US_TOPIC_0000001188482166__li41661111245"><strong id="EN-US_TOPIC_0000001188482166__b166221112173815">source_filepath</strong>: file path on the OBS server. Only .jar files are supported.</li><li id="EN-US_TOPIC_0000001188482166__li89193292211"><strong id="EN-US_TOPIC_0000001188482166__b1406172965113">accesskey</strong>: key obtained for accessing the OBS service. It is mandatory.</li><li id="EN-US_TOPIC_0000001188482166__li474455331"><strong id="EN-US_TOPIC_0000001188482166__b14676132165217">secret_key</strong>: secret key obtained for the OBS service. It is mandatory.</li><li id="EN-US_TOPIC_0000001188482166__li83828343534"><strong id="EN-US_TOPIC_0000001188482166__b1673012327559">region</strong>: region where the OBS bucket stored in the JAR package of a user-defined function belongs to. This parameter is mandatory. </li><li id="EN-US_TOPIC_0000001188482166__li566271617316"><strong id="EN-US_TOPIC_0000001188482166__b84423223019">libraryname</strong>: user-defined library name, which is used to invoke JAR files in <span id="EN-US_TOPIC_0000001188482166__text737749401">GaussDB(DWS)</span>. If <strong id="EN-US_TOPIC_0000001188482166__b15714396176">action</strong> is set to <strong id="EN-US_TOPIC_0000001188482166__b75274811715">addjar</strong> or <strong id="EN-US_TOPIC_0000001188482166__b85064124183">rmjar</strong>, <strong id="EN-US_TOPIC_0000001188482166__b983817260184">libraryname</strong> must be specified. If <strong id="EN-US_TOPIC_0000001188482166__b546493417182">action</strong> is set to <strong id="EN-US_TOPIC_0000001188482166__b1120183891810">ls</strong>, <strong id="EN-US_TOPIC_0000001188482166__b3432124711815">libraryname</strong> is optional. Note that a user-defined library name cannot contain the following characters: /|;&amp;$&lt;&gt;\'{}"()[]~*?!</li></ul>
</li></ul>
</div></div>
</li><li id="EN-US_TOPIC_0000001188482166__li1541715862915"><a name="EN-US_TOPIC_0000001188482166__li1541715862915"></a><a name="li1541715862915"></a>Create functions.<p id="EN-US_TOPIC_0000001188482166__p1311925173017"><a name="EN-US_TOPIC_0000001188482166__li1541715862915"></a><a name="li1541715862915"></a>PL/Java functions can be created using the <strong id="EN-US_TOPIC_0000001188482166__b11245222201112">CREATE FUNCTION</strong> syntax and are defined as <strong id="EN-US_TOPIC_0000001188482166__b1199417317118">LANGUAGE JAVA</strong>, including the <strong id="EN-US_TOPIC_0000001188482166__b12420163816117">RETURNS</strong> and <strong id="EN-US_TOPIC_0000001188482166__b9296134051118">AS</strong> clauses.</p>
<ul id="EN-US_TOPIC_0000001188482166__ul8450104931314"><li id="EN-US_TOPIC_0000001188482166__li12738939181318">To use <strong id="EN-US_TOPIC_0000001188482166__b2292168105415">CREATE FUNCTION</strong>, specify the name and parameter type for the function to be created.</li><li id="EN-US_TOPIC_0000001188482166__li9760539101312">The <strong id="EN-US_TOPIC_0000001188482166__b5867320105520">RETURNS</strong> clause specifies the return type for the function.</li><li id="EN-US_TOPIC_0000001188482166__li1176163911310">The <strong id="EN-US_TOPIC_0000001188482166__b923332015123">AS</strong> clause specifies the class name and static method name of the Java method to be invoked. If the <strong id="EN-US_TOPIC_0000001188482166__b929573051210">NULL</strong> value needs to be transferred to the Java method as an input parameter, specify the name of the Java encapsulation class corresponding to the parameter type. For details, see <a href="#EN-US_TOPIC_0000001188482166__section11546180328">NULL Handling</a>.</li><li id="EN-US_TOPIC_0000001188482166__li15458121419253">For details about the syntax, see CREATE FUNCTION.<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001188482166__screen15458181482520"><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></pre></div></td><td class="code"><div><pre><span></span><span class="n">CREATE</span><span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="n">OR</span><span class="w"> </span><span class="n">REPLACE</span><span class="w"> </span><span class="o">]</span><span class="w"> </span><span class="n">FUNCTION</span><span class="w"> </span><span class="nf">function_name</span>
<span class="p">(</span><span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">argname</span><span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="n">argmode</span><span class="w"> </span><span class="o">]</span><span class="w"> </span><span class="n">argtype</span><span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">DEFAULT</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="p">:</span><span class="o">=</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="n">expression</span><span class="w"> </span><span class="o">]</span><span class="p">}</span><span class="w"> </span><span class="o">[</span><span class="p">,</span><span class="w"> </span><span class="p">...</span><span class="o">]</span><span class="w"> </span><span class="o">]</span><span class="p">)</span>
<span class="o">[</span><span class="w"> </span><span class="n">RETURNS</span><span class="w"> </span><span class="n">rettype</span><span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="n">DETERMINISTIC</span><span class="w"> </span><span class="o">]</span><span class="w"> </span><span class="o">]</span>
<span class="n">LANGAUGE</span><span class="w"> </span><span class="n">JAVA</span>
<span class="o">[</span>
<span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">IMMUTABLE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">STATBLE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">VOLATILE</span><span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="n">NOT</span><span class="w"> </span><span class="o">]</span><span class="w"> </span><span class="n">LEAKPROOF</span>
<span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">WINDOW</span>
<span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">CALLED</span><span class="w"> </span><span class="n">ON</span><span class="w"> </span><span class="n">NULL</span><span class="w"> </span><span class="n">INPUT</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">RETURNS</span><span class="w"> </span><span class="n">NULL</span><span class="w"> </span><span class="n">ON</span><span class="w"> </span><span class="n">NULL</span><span class="w"> </span><span class="n">INPUT</span><span class="w"> </span><span class="o">|</span><span class="n">STRICT</span><span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="o">[</span><span class="w"> </span><span class="n">EXTERNAL</span><span class="w"> </span><span class="o">]</span><span class="w"> </span><span class="n">SECURITY</span><span class="w"> </span><span class="n">INVOKER</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="n">EXTERNAL</span><span class="w"> </span><span class="o">]</span><span class="w"> </span><span class="n">SECURITY</span><span class="w"> </span><span class="n">DEFINER</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">AUTHID</span><span class="w"> </span><span class="n">DEFINER</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">AUTHID</span><span class="w"> </span><span class="n">CURRENT_USER</span><span class="p">}</span>
<span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">FENCED</span><span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">COST</span><span class="w"> </span><span class="n">execution_cost</span>
<span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">ROWS</span><span class="w"> </span><span class="n">result_rows</span>
<span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">SET</span><span class="w"> </span><span class="n">configuration_parameter</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">{</span><span class="n">TO</span><span class="w"> </span><span class="o">|=</span><span class="p">}</span><span class="w"> </span><span class="n">value</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">FROM</span><span class="w"> </span><span class="n">CURRENT</span><span class="p">}</span>
<span class="o">]</span><span class="w"> </span><span class="o">[</span><span class="p">...</span><span class="o">]</span>
<span class="p">{</span>
<span class="w"> </span><span class="n">AS</span><span class="w"> </span><span class="err">'</span><span class="n">class_name</span><span class="p">.</span><span class="na">method_name</span><span class="err">'</span><span class="w"> </span><span class="p">(</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">argtype</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">[</span><span class="p">,</span><span class="w"> </span><span class="p">...</span><span class="o">]</span><span class="w"> </span><span class="p">)</span>
<span class="p">}</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
</li><li id="EN-US_TOPIC_0000001188482166__li161941319300">Use functions.<p id="EN-US_TOPIC_0000001188482166__p131836393217"><a name="EN-US_TOPIC_0000001188482166__li161941319300"></a><a name="li161941319300"></a>During execution, PL/Java searches for the Java class specified by a function among all the deployed JAR packages, which are ranked by name in alphabetical order, invokes the Java method in the first found class, and returns results.</p>
</li><li id="EN-US_TOPIC_0000001188482166__li177208542464">Delete functions.<p id="EN-US_TOPIC_0000001188482166__p314917318321"><a name="EN-US_TOPIC_0000001188482166__li177208542464"></a><a name="li177208542464"></a>PL/Java functions can be deleted by using the <strong id="EN-US_TOPIC_0000001188482166__b168715361892">DROP FUNCTION</strong> syntax. For details about the syntax, see DROP FUNCTION.</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen6274172217820">DROP FUNCTION [ IF EXISTS ] function_name [ ( [ {[ argmode ] [ argname ] argtype} [, ...] ] ) [ CASCADE | RESTRICT ] ];</pre>
<p id="EN-US_TOPIC_0000001188482166__p414923103215">To delete an overloaded function (for details, see <a href="#EN-US_TOPIC_0000001188482166__section13355162616820">Overloaded Functions</a>), specify <strong id="EN-US_TOPIC_0000001188482166__b324844212016">argtype</strong> in the function. To delete other functions, simply specify <strong id="EN-US_TOPIC_0000001188482166__b4350102313018">function_name</strong>.</p>
</li><li id="EN-US_TOPIC_0000001188482166__li19929482465"><a name="EN-US_TOPIC_0000001188482166__li19929482465"></a><a name="li19929482465"></a>Authorize permissions for functions.<p id="EN-US_TOPIC_0000001188482166__p154972317332"><a name="EN-US_TOPIC_0000001188482166__li19929482465"></a><a name="li19929482465"></a>Only user <strong id="EN-US_TOPIC_0000001188482166__b1418165681416">sysadmin</strong> can create PL/Java functions. It can also grant other users the permission to use the PL/Java functions. For details about the syntax, see GRANT.</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen1534510484810">GRANT { EXECUTE | ALL [ PRIVILEGES ] }
ON { FUNCTION {function_name ( [ {[ argmode ] [ arg_name ] arg_type} [, ...] ] )} [, ...]
| ALL FUNCTIONS IN SCHEMA schema_name [, ...] }
TO { [ GROUP ] role_name | PUBLIC } [, ...]
[ WITH GRANT OPTION ];</pre>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482166__section2828135511337"><h4 class="sectiontitle">Mapping for Basic Data Types</h4>
<div class="tablenoborder"><a name="EN-US_TOPIC_0000001188482166__table10200627143416"></a><a name="table10200627143416"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188482166__table10200627143416" frame="border" border="1" rules="all"><caption><b>Table 1 </b>PL/Java mapping for default data types</caption><thead align="left"><tr id="EN-US_TOPIC_0000001188482166__row52006273347"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.5.2.2.3.1.1"><p id="EN-US_TOPIC_0000001188482166__p12221055173619"><span id="EN-US_TOPIC_0000001188482166__text1858749099">GaussDB(DWS)</span></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.5.2.2.3.1.2"><p id="EN-US_TOPIC_0000001188482166__p182285553613"><strong id="EN-US_TOPIC_0000001188482166__b222555123617">Java</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188482166__row16200102783419"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p1322105512361">BOOLEAN</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p1922175514367">boolean</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row132001827103418"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p1623155517366">"char"</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p22365583612">byte</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row192001627153420"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p1124175533612">bytea</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p324165512366">byte[]</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row52011027113413"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p1824155533619">SMALLINT</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p1424955103619">short</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row520182783411"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p32475516360">INTEGER</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p72485573617">int</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row2126124903615"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p112415517366">BIGINT</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p12410551363">long</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row113734619364"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p1224175519367">FLOAT4</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p1324155513366">float</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row1220119277343"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p4245552369">FLOAT8</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p132415556365">double</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row194001343143617"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p524055113617">CHAR</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p024195516368">java.lang.String</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row989924003617"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p1724155512367">VARCHAR</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p192418558360">java.lang.String</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row120172753416"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p92475512360">TEXT</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p132411553366">java.lang.String</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row1154313281354"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p42455515364">name</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p92645513367">java.lang.String</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row627313814365"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p426125515368">DATE</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p626175533613">java.sql.Timestamp</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row9126123918355"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p142695523610">TIME</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p2261855153620">java.sql.Time (stored value treated as local time)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row47181243113513"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p1826055193619">TIMETZ</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p726165553613">java.sql.Time</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row16150193563516"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p52755593616">TIMESTAMP</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p02745533610">java.sql.Timestamp</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row1445023473613"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p9278556361">TIMESTAMPTZ</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p927135543614">java.sql.Timestamp</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482166__section158345559331"><h4 class="sectiontitle">Array Type Processing</h4><p id="EN-US_TOPIC_0000001188482166__p1435059163718"><span id="EN-US_TOPIC_0000001188482166__text102181137">GaussDB(DWS)</span> can convert basic array types. You only need to append a pair of square brackets ([]) to the data type when creating a function.</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen93421386913">CREATE FUNCTION java_arrayLength(INTEGER[])
RETURNS INTEGER
AS 'Example.getArrayLength'
LANGUAGE JAVA;</pre>
<p id="EN-US_TOPIC_0000001188482166__p330203815385">Java code is similar to the following:</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen156461932092">public class Example
{
public static int getArrayLength(Integer[] intArray)
{
return intArray.length;
}
}</pre>
<p id="EN-US_TOPIC_0000001188482166__p971318401386">Invoke the following statement:</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen145151466101">SELECT java_arrayLength(ARRAY[1, 2, 3]);</pre>
<p id="EN-US_TOPIC_0000001188482166__p10211524143917">The expected result is as follows:</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen2506759091">java_arrayLength
---------------------
3
(1 row)</pre>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482166__section11546180328"><a name="EN-US_TOPIC_0000001188482166__section11546180328"></a><a name="section11546180328"></a><h4 class="sectiontitle">NULL Handling</h4><p id="EN-US_TOPIC_0000001188482166__p15709195103819">NULL values cannot be handled for <span id="EN-US_TOPIC_0000001188482166__text105792299">GaussDB(DWS)</span> data types that are mapped and can be converted to simple Java types by default. If you use a Java function to obtain and process the <strong id="EN-US_TOPIC_0000001188482166__b106123503166">NULL</strong> value transferred from <span id="EN-US_TOPIC_0000001188482166__text1577486310">GaussDB(DWS)</span>, specify the Java encapsulation class in the <strong id="EN-US_TOPIC_0000001188482166__b2331149177">AS</strong> clause as follows:</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen1652982251013">CREATE FUNCTION java_countnulls(INTEGER[])
RETURNS INTEGER
AS 'Example.countNulls(java.lang.Integer[])'
LANGUAGE JAVA;</pre>
<p id="EN-US_TOPIC_0000001188482166__p16645571741">Java code is similar to the following:</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen26525293106">public class Example
{
public static int countNulls(Integer[] intArray)
{
int nullCount = 0;
for (int idx = 0; idx &lt; intArray.length; ++idx)
{
if (intArray[idx] == null)
nullCount++;
}
return nullCount;
}
}</pre>
<p id="EN-US_TOPIC_0000001188482166__p16748491243">Invoke the following statement:</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen123483469105">SELECT java_countNulls(ARRAY[null, 1, null, 2, null]);</pre>
<p id="EN-US_TOPIC_0000001188482166__p1677134415514">The expected result is as follows:</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen18918640201017">java_countNulls
--------------------
3
(1 row)</pre>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482166__section13355162616820"><a name="EN-US_TOPIC_0000001188482166__section13355162616820"></a><a name="section13355162616820"></a><h4 class="sectiontitle">Overloaded Functions</h4><p id="EN-US_TOPIC_0000001188482166__p12954153711818">PL/Java supports overloaded functions. You can create functions with the same name or invoke overloaded functions from Java code. The procedure is as follows:</p>
<ol id="EN-US_TOPIC_0000001188482166__ol176722021120"><li id="EN-US_TOPIC_0000001188482166__li136732081119"><span>Create overloaded functions.</span><p><p id="EN-US_TOPIC_0000001188482166__p1234416114194">For example, create two Java methods with the same name, and specify the methods dummy(int) and dummy(String) with different parameter types.</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen43309327218">public class Example
{
public static int dummy(int value)
{
return value*2;
}
public static String dummy(String value)
{
return value;
}
}</pre>
<p id="EN-US_TOPIC_0000001188482166__p7174183531918">In addition, create two functions with the same names as the above two functions in <span id="EN-US_TOPIC_0000001188482166__text2085624622">GaussDB(DWS)</span>.</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen12661355112117">CREATE FUNCTION java_dummy(INTEGER)
RETURNS INTEGER
AS 'Example.dummy'
LANGUAGE JAVA;
CREATE FUNCTION java_dummy(VARCHAR)
RETURNS VARCHAR
AS 'Example.dummy'
LANGUAGE JAVA;</pre>
</p></li><li id="EN-US_TOPIC_0000001188482166__li164646554181"><span>Invoke the overloaded functions.</span><p><p id="EN-US_TOPIC_0000001188482166__p49938325203"><span id="EN-US_TOPIC_0000001188482166__text1151137651">GaussDB(DWS)</span> invokes the functions that match the specified parameter type. The results of invoking the above two functions are as follows:</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen153318328227">SELECT java_dummy(5);
java_dummy
-----------------
10
(1 row)
SELECT java_dummy('5');
java_dummy
---------------
5
(1 row)</pre>
<p id="EN-US_TOPIC_0000001188482166__p958525892015">Note that <span id="EN-US_TOPIC_0000001188482166__text716706362">GaussDB(DWS)</span> may implicitly convert data types. Therefore, you are advised to specify the parameter type when invoking an overloaded function.</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen191414617222">SELECT java_dummy(5::varchar);
java_dummy
----------------
5
(1 row)</pre>
<p id="EN-US_TOPIC_0000001188482166__p17321950202011">In this case, the specified parameter type is preferentially used for matching. If there is no Java method matching the specified parameter type, the system implicitly converts the parameter and searches for Java methods based on the conversion result.</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen43601022142310">SELECT java_dummy(5::INTEGER);
java_dummy
-----------------
10
(1 row)
DROP FUNCTION java_dummy(INTEGER);
SELECT java_dummy(5::INTEGER);
java_dummy
----------------
5
(1 row)</pre>
<div class="notice" id="EN-US_TOPIC_0000001188482166__note107881957182110"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="EN-US_TOPIC_0000001188482166__p1078865752112">Data types supporting implicit conversion are as follows:</p>
<ul id="EN-US_TOPIC_0000001188482166__ul652217119222"><li id="EN-US_TOPIC_0000001188482166__li1652231142217"><strong id="EN-US_TOPIC_0000001188482166__b1982185117375">SMALLINT</strong>: It can be converted to the <strong id="EN-US_TOPIC_0000001188482166__b1597253143810">INTEGER</strong> type by default.</li><li id="EN-US_TOPIC_0000001188482166__li2076933122213"><strong id="EN-US_TOPIC_0000001188482166__b5786105923812">SMALLINT</strong> and <strong id="EN-US_TOPIC_0000001188482166__b347343143914">INTEGER</strong>: They can be converted to the <strong id="EN-US_TOPIC_0000001188482166__b3223115443812">BIGINT</strong> type by default.</li><li id="EN-US_TOPIC_0000001188482166__li1318184314236"><strong id="EN-US_TOPIC_0000001188482166__b1449515304392">TINYINT</strong>, <strong id="EN-US_TOPIC_0000001188482166__b71980327394">SMALLINT</strong>, <strong id="EN-US_TOPIC_0000001188482166__b11385183310396">INTEGER</strong>, and <strong id="EN-US_TOPIC_0000001188482166__b14838153453919">BIGINT</strong>: They can be converted to the <strong id="EN-US_TOPIC_0000001188482166__b1259862214390">BOOL</strong> type by default.</li><li id="EN-US_TOPIC_0000001188482166__li12860144318238"><strong id="EN-US_TOPIC_0000001188482166__b102927459399">CHAR</strong>, <strong id="EN-US_TOPIC_0000001188482166__b187755469396">NAME</strong>, <strong id="EN-US_TOPIC_0000001188482166__b18589148123914">BIGINT</strong>, <strong id="EN-US_TOPIC_0000001188482166__b1891624913396">INTEGER</strong>, <strong id="EN-US_TOPIC_0000001188482166__b637085103916">SMALLINT</strong>, <strong id="EN-US_TOPIC_0000001188482166__b227615315395">TINYINT</strong>, <strong id="EN-US_TOPIC_0000001188482166__b6417755133916">RAW</strong>, <strong id="EN-US_TOPIC_0000001188482166__b109951956103913">FLOAT4</strong>, <strong id="EN-US_TOPIC_0000001188482166__b153701358193915">FLOAT8</strong>, <strong id="EN-US_TOPIC_0000001188482166__b587018384016">BPCHAR</strong>, <strong id="EN-US_TOPIC_0000001188482166__b754214617407">VARCHAR</strong>, <strong id="EN-US_TOPIC_0000001188482166__b2088515854013">NVARCHAR2</strong>, <strong id="EN-US_TOPIC_0000001188482166__b4542510104011">DATE</strong>, <strong id="EN-US_TOPIC_0000001188482166__b7885212124017">TIMESTAMP</strong>, <strong id="EN-US_TOPIC_0000001188482166__b6120131514405">TIMESTAMPTZ</strong>, <strong id="EN-US_TOPIC_0000001188482166__b68915198404">NUMERIC</strong>, and <strong id="EN-US_TOPIC_0000001188482166__b0604021174018">SMALLDATETIME</strong>: They can be converted to the <strong id="EN-US_TOPIC_0000001188482166__b13644443134014">TEXT</strong> type by default.</li><li id="EN-US_TOPIC_0000001188482166__li1980785322317"><strong id="EN-US_TOPIC_0000001188482166__b156354391662">TEXT</strong>, <strong id="EN-US_TOPIC_0000001188482166__b1710320168424">CHAR</strong>, <strong id="EN-US_TOPIC_0000001188482166__b57448193424">BIGINT</strong>, <strong id="EN-US_TOPIC_0000001188482166__b1643116216424">INTEGER</strong>, <strong id="EN-US_TOPIC_0000001188482166__b1352582474210">SMALLINT</strong>, <strong id="EN-US_TOPIC_0000001188482166__b11744142684210">TINYINT</strong>, <strong id="EN-US_TOPIC_0000001188482166__b275918286422">RAW</strong>, <strong id="EN-US_TOPIC_0000001188482166__b17455183112429">FLOAT4</strong>, <strong id="EN-US_TOPIC_0000001188482166__b6408153354217">FLOAT8</strong>, <strong id="EN-US_TOPIC_0000001188482166__b111891935134215">BPCHAR</strong>, <strong id="EN-US_TOPIC_0000001188482166__b1659536154210">DATE</strong>, <strong id="EN-US_TOPIC_0000001188482166__b7173739114210">NVARCHAR2</strong>, <strong id="EN-US_TOPIC_0000001188482166__b12424184214219">TIMESTAMP</strong>, <strong id="EN-US_TOPIC_0000001188482166__b2549154510421">NUMERIC</strong>, and <strong id="EN-US_TOPIC_0000001188482166__b14268185011420">SMALLDATETIME</strong>: They can be converted to the <strong id="EN-US_TOPIC_0000001188482166__b1861252424110">VARCHAR</strong> type by default.</li></ul>
</div></div>
</p></li><li id="EN-US_TOPIC_0000001188482166__li4857182942014"><span>Delete the overloaded functions.</span><p><p id="EN-US_TOPIC_0000001188482166__p1551817177241">To delete an overloaded function, specify the parameter type for the function. Otherwise, the function cannot be deleted.</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen78947574233">DROP FUNCTION java_dummy(INTEGER);</pre>
</p></li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482166__section1523193734418"><h4 class="sectiontitle">GUC Parameters</h4>
<ul id="EN-US_TOPIC_0000001188482166__ul17268132515289"><li id="EN-US_TOPIC_0000001188482166__li11268102552815"><strong id="EN-US_TOPIC_0000001188482166__b126832518284">FencedUDFMemoryLimit</strong><p id="EN-US_TOPIC_0000001188482166__p226892562812">A session-level GUC parameter. It is used to specify the maximum virtual memory used by a single Fenced UDF Worker process initiated by a session.</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen18179162014292">SET FencedUDFMemoryLimit='512MB';</pre>
<p id="EN-US_TOPIC_0000001188482166__p1526832519286">The value range of this parameter is (<strong id="EN-US_TOPIC_0000001188482166__b1863091752216">150 MB</strong>, <strong id="EN-US_TOPIC_0000001188482166__b4945145214437">1G</strong>). If the value is greater than <strong id="EN-US_TOPIC_0000001188482166__b18552219204415">1G</strong>, an error will be reported immediately. If the value is less than or equal to <strong id="EN-US_TOPIC_0000001188482166__b17424416122311">150 MB</strong>, an error will be reported during function invoking.</p>
<div class="notice" id="EN-US_TOPIC_0000001188482166__note9268182510284"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><ul id="EN-US_TOPIC_0000001188482166__ul22682025112816"><li id="EN-US_TOPIC_0000001188482166__li1955514541565">If <strong id="EN-US_TOPIC_0000001188482166__b2348125913305">FencedUDFMemoryLimit</strong> is set to <strong id="EN-US_TOPIC_0000001188482166__b1645661193112">0</strong>, the virtual memory for a Fenced UDF Worker process will not be limited.</li><li id="EN-US_TOPIC_0000001188482166__li8206143847">You are advised to use <strong id="EN-US_TOPIC_0000001188482166__b3747152717311">udf_memory_limit</strong> to control the physical memory used by Fenced UDF Worker processes. You are not advised to use <strong id="EN-US_TOPIC_0000001188482166__b65601722173220">FencedUDFMemoryLimit</strong>, especially when Java UDFs are used. If you are clear about the impact of this parameter, set it based on the following information:<ul id="EN-US_TOPIC_0000001188482166__ul319312551320"><li id="EN-US_TOPIC_0000001188482166__li1532915220131">After a C Fenced UDF Worker process is started, it will occupy about 200 MB virtual memory, and about 16 MB physical memory.</li><li id="EN-US_TOPIC_0000001188482166__li19350152281314">After a Java Fenced UDF Worker process is started, it will occupy about 2.5 GB virtual memory, and about 50 MB physical memory.</li></ul>
</li></ul>
</div></div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482166__section61752311427"><h4 class="sectiontitle">Exception Handling</h4><p id="EN-US_TOPIC_0000001188482166__p1865165117212">If there is an exception in a JVM, PL/Java will export JVM stack information during the exception to a client.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482166__section1349616571294"><h4 class="sectiontitle">Logging</h4><p id="EN-US_TOPIC_0000001188482166__p83305591590">PL/Java uses the standard Java Logger. Therefore, you can record logs as follows:</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen14235171310502">Logger.getAnonymousLogger().config( "Time is " + new
Date(System.currentTimeMillis()));</pre>
<p id="EN-US_TOPIC_0000001188482166__p42268122103">An initialized Java Logger class is set to the <strong id="EN-US_TOPIC_0000001188482166__b1068619283281">CONFIG</strong> level by default, corresponding to the <strong id="EN-US_TOPIC_0000001188482166__b865993452820">LOG</strong> level in <span id="EN-US_TOPIC_0000001188482166__text254009958">GaussDB(DWS)</span>. In this case, log messages generated by Java Logger are all redirected to the <span id="EN-US_TOPIC_0000001188482166__text236565644">GaussDB(DWS)</span> backend. Then, the log messages are written into server logs or displayed on the user interface. MPPDB server logs record information at the <strong id="EN-US_TOPIC_0000001188482166__b534234319319">LOG</strong>, <strong id="EN-US_TOPIC_0000001188482166__b4640144453111">WARNING</strong>, and <strong id="EN-US_TOPIC_0000001188482166__b36875467317">ERROR</strong> levels. The SQL user interface displays logs at the <strong id="EN-US_TOPIC_0000001188482166__b1347413343214">WARNING</strong> and <strong id="EN-US_TOPIC_0000001188482166__b1234995183213">ERROR</strong> levels. The following table lists mapping between Java Logger levels and <span id="EN-US_TOPIC_0000001188482166__text2065008186">GaussDB(DWS)</span> log levels.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188482166__table11174544161020" frame="border" border="1" rules="all"><caption><b>Table 2 </b>PL/Java log levels</caption><thead align="left"><tr id="EN-US_TOPIC_0000001188482166__row51752044111020"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.11.5.2.3.1.1"><p id="EN-US_TOPIC_0000001188482166__p6828651131016"><strong id="EN-US_TOPIC_0000001188482166__b482818513107">java.util.logging.Level</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.11.5.2.3.1.2"><p id="EN-US_TOPIC_0000001188482166__p1482814513102"><strong id="EN-US_TOPIC_0000001188482166__b8302140145310"><span id="EN-US_TOPIC_0000001188482166__text129870107">GaussDB(DWS)</span></strong> <strong id="EN-US_TOPIC_0000001188482166__b1016054916542">Log Level</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188482166__row10175444121019"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p2082810515100"><strong id="EN-US_TOPIC_0000001188482166__b6828185141012">SERVER</strong></p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p582835161014">ERROR</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row81754442109"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p13828351131019"><strong id="EN-US_TOPIC_0000001188482166__b198288512108">WARNING</strong></p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p1482885119107">WARNING</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row1917512443102"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p1782895151016"><strong id="EN-US_TOPIC_0000001188482166__b9828251111014">CONFIG</strong></p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p282885121016">LOG</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row617544410102"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p1282825112107"><strong id="EN-US_TOPIC_0000001188482166__b582812511103">INFO</strong></p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p182865116108">INFO</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row18175184481016"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p13829951151015"><strong id="EN-US_TOPIC_0000001188482166__b98293512104">FINE</strong></p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p198291751151010">DEBUG1</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row131753443103"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p14829205117109"><strong id="EN-US_TOPIC_0000001188482166__b198291351121012">FINER</strong></p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p182965112101">DEBUG2</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001188482166__row8175194411102"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.1 "><p id="EN-US_TOPIC_0000001188482166__p1829195141016"><strong id="EN-US_TOPIC_0000001188482166__b20829125161011">FINEST</strong></p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.5.2.3.1.2 "><p id="EN-US_TOPIC_0000001188482166__p1682995141011">DEBUG3</p>
</td>
</tr>
</tbody>
</table>
</div>
<p id="EN-US_TOPIC_0000001188482166__p1017619913113">You can change Java Logger levels. For example, if the Java Logger level is changed to <strong id="EN-US_TOPIC_0000001188482166__b1144735825716">SEVERE</strong> by the following Java code, log messages (<strong id="EN-US_TOPIC_0000001188482166__b10449135885719">msg</strong>) will not be recorded in <span id="EN-US_TOPIC_0000001188482166__text276041905">GaussDB(DWS)</span> logs during <strong id="EN-US_TOPIC_0000001188482166__b1645155845720">WARNING</strong> logging.</p>
<pre class="screen" id="EN-US_TOPIC_0000001188482166__screen210685274915">Logger log = Logger.getAnonymousLogger();
Log.setLevel(Level.SEVERE);
log.log(Level.WARNING, msg);</pre>
</div>
<div class="section" id="EN-US_TOPIC_0000001188482166__section106351333166"><h4 class="sectiontitle">Security Issues</h4><p id="EN-US_TOPIC_0000001188482166__p61702193167">In <span id="EN-US_TOPIC_0000001188482166__text548702939">GaussDB(DWS)</span>, PL/Java is an untrusted language. Only user <strong id="EN-US_TOPIC_0000001188482166__b9438155164314">sysadmin</strong> can create PL/Java functions. The user can grant other users the permission for using the PL/Java functions. For details, see <a href="#EN-US_TOPIC_0000001188482166__li19929482465">Authorize permissions for functions</a>.</p>
<p id="EN-US_TOPIC_0000001188482166__p13170141910161">In addition, PL/Java controls user access to file systems, forbidding users from reading most system files, or writing, deleting, or executing any system files in Java methods.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0507.html">User-Defined Functions</a></div>
</div>
</div>