4
<meta http-equiv="Content-Language" content="en-us">
5
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6
<title>PL/Java and PosgreSQL 8</title>
11
<h1>PL/Java and PostgreSQL 8.0</h1>
12
<p><font size="2">Java™ is a registered trademark of Sun Microsystems, Inc. in the United States and other countries.</font></p><br/>
13
<p>PostgreSQL introduces a couple of new features that PL/Java make use of.</p>
14
<h2>Exception handling</h2>
15
<p>It is now possible to catch and handle an exception in the Postgres backend.
16
While it was possible to catch an exception in earlier Postgres versions as
17
well, there was no way to prevent the generated message from being printed, nor
18
to find out what the error was. The nested transaction concept introduced with
19
8.0 forced this to change and Postgres introduced a try/catch system and a
20
structure called <code>ErrorData</code> that can be used when investigating the
21
cause of an exception. PL/Java fully exploits this. The <code>ErrorData</code> is
22
exposed as a property in a class called <code>
23
org.postgresql.pljava.ServerException</code> (derived from
24
<code>java.sql.SQLException</code>) and the Java try/catch mechanism is
25
synchronized with the backend mechanism.</p>
27
PostgreSQL savepoints are exposed using the <code>java.sql.Connection</code>
28
interface. Two restrictions apply.<ul>
29
<li>A savepoint must be rolled back or released in the function where it was
31
<li>A savepoint must not outlife the function where it was set</li>
33
<h2>Module configuration.</h2>
34
<p>Postgres 8.0 introduces the concept of <i>custom variable classes</i> in the
35
<code>postgresql.conf</code> configuration file to enable modules like PL/Java to
36
add their own configuration parameters. Normally, any variable name that the
37
postmaster cannot recognize will generate an error. Now, with a custom variable
38
class, a module can add a class of variables that the postmaster will accept.
39
It's then up to the module to verify their correctness.</p>
40
<p>Please note that custom variables can be set using the SQL SET command also,
41
just like most other variables.</p>
42
<p>PL/Java introduces a custom variable class named "pljava" and some variables.
43
Here's a sample postgresql.conf entry using all (3) of the variables currently
45
<pre># define "pljava" as a custom variable class. This is a comma separated
48
custom_variable_classes = 'pljava'
50
# define the class path that the JVM will use when loading the
51
# initial library. Only meaningful for non GJC installations
53
pljava.classpath = '/home/Tada/pljava/build/pljava.jar'
55
# Set the size of the prepared statement MRU cache
57
pljava.statement_cache_size = 10
59
# If true, lingering savepoints will be released on function exit. If false,
60
# the will be rolled back
62
pljava.release_lingering_savepoints = true
64
# Define startup options for the Java VM.
66
pljava.vmoptions = '-Xmx64M'
68
# Setting debug to true will cause the postgres process to go
69
# into a sleep(1) loop on its first call to java. This is
70
# only useful if you want to debug the PL/Java internal C code.
72
pljava.debug = false</pre>
b'\\ No newline at end of file'