Java™ is a registered trademark of Sun Microsystems, Inc. in the United States and other countries.
PostgreSQL introduces a couple of new features that PL/Java make use of.
It is now possible to catch and handle an exception in the Postgres backend.
While it was possible to catch an exception in earlier Postgres versions as
well, there was no way to prevent the generated message from being printed, nor
to find out what the error was. The nested transaction concept introduced with
8.0 forced this to change and Postgres introduced a try/catch system and a
structure called ErrorData
that can be used when investigating the
cause of an exception. PL/Java fully exploits this. The ErrorData
is
exposed as a property in a class called
org.postgresql.pljava.ServerException
(derived from
java.sql.SQLException
) and the Java try/catch mechanism is
synchronized with the backend mechanism.
java.sql.Connection
interface. Two restrictions apply.Postgres 8.0 introduces the concept of custom variable classes in the
postgresql.conf
configuration file to enable modules like PL/Java to
add their own configuration parameters. Normally, any variable name that the
postmaster cannot recognize will generate an error. Now, with a custom variable
class, a module can add a class of variables that the postmaster will accept.
It's then up to the module to verify their correctness.
Please note that custom variables can be set using the SQL SET command also, just like most other variables.
PL/Java introduces a custom variable class named "pljava" and some variables. Here's a sample postgresql.conf entry using all (3) of the variables currently introduced:
# define "pljava" as a custom variable class. This is a comma separated # list of names. # custom_variable_classes = 'pljava' # define the class path that the JVM will use when loading the # initial library. Only meaningful for non GJC installations # pljava.classpath = '/home/Tada/pljava/build/pljava.jar' # Set the size of the prepared statement MRU cache # pljava.statement_cache_size = 10 # If true, lingering savepoints will be released on function exit. If false, # the will be rolled back # pljava.release_lingering_savepoints = true # Define startup options for the Java VM. # pljava.vmoptions = '-Xmx64M' # Setting debug to true will cause the postgres process to go # into a sleep(1) loop on its first call to java. This is # only useful if you want to debug the PL/Java internal C code. # pljava.debug = false