org.postgresql.pljava.management
Class Commands

java.lang.Object
  extended byorg.postgresql.pljava.management.Commands

public class Commands
extends java.lang.Object

This methods of this class are implementations of SQLJ commands.

SQJL functions

install_jar

The install_jar command loads a jarfile from a location appointed by an URL into the SQLJ jar repository. It is an error if a jar with the given name already exists in the repository.

Usage

SELECT sqlj.install_jar(<jar_url>, <jar_name>, ;<deploy>);

Parameters

jar_url The URL that denotes the location of the jar that should be loaded
jar_name This is the name by which this jar can be referenced once it has been loaded
deploy True if the jar should be deployed according to a deployment descriptor, false otherwise

replace_jar

The replace_jar will replace a loaded jar with another jar. Use this command to update already loaded files. It's an error if the jar is not found.

Usage

SELECT sqlj.replace_jar(<jar_url>, <jar_name>, ;<redeploy>);

Parameters

jar_url The URL that denotes the location of the jar that should be loaded
jar_name The name of the jar to be replaced
redeploy True if the old and new jar should be undeployed and deployed according to their respective deployment descriptors, false otherwise

remove_jar

The remove_jar will drop the jar from the jar repository. Any classpath that references this jar will be updated accordingly. It's an error if the jar is not found.

Usage

SELECT sqlj.remove_jar(<jar_name>, <undeploy>);

Parameters

jar_name The name of the jar to be removed
undeploy True if the jar should be undeployed according to its deployment descriptor, false otherwise

get_classpath

The get_classpath will return the classpath that has been defined for the given schema or NULL if the schema has no classpath. It's an error if the given schema does not exist.

Usage

SELECT sqlj.get_classpath(<schema>);

Parameters

schema The name of the schema

set_classpath

The set_classpath will define a classpath for the given schema. A classpath consists of a colon separated list of jar names. It's an error if the given schema does not exist or if one or more jar names references non existent jars.

Usage

SELECT sqlj.set_classpath(<schema>, <classpath>);

Parameters

schema The name of the schema
classpath The colon separated list of jar names


Constructor Summary
Commands()
           
 
Method Summary
static void addClassImages(java.sql.Connection conn, int jarId, java.lang.String urlString)
          Reads the jar found at the specified URL and stores the entries in the jar_entry table.
protected static void assertJarName(java.lang.String jarName)
          Throws an exception if the given name cannot be used as the name of a jar.
protected static void deployInstall(java.sql.Connection conn, int jarId)
           
protected static void deployRemove(java.sql.Connection conn, int jarId)
           
static java.lang.String getClassPath(java.lang.String schemaName)
          Return the classpath that has been defined for the schema named schemaName This method is exposed in SQL as sqlj.get_classpath(VARCHAR).
protected static SQLDeploymentDescriptor getDeploymentDescriptor(java.sql.Connection conn, int jarId)
           
protected static int getJarId(java.sql.Connection conn, java.lang.String jarName, AclId[] ownerRet)
          Returns the primary key identifier for the given Jar.
protected static Oid getSchemaId(java.sql.Connection conn, java.lang.String schemaName)
          Returns the Oid for the given Schema.
static void installJar(java.lang.String urlString, java.lang.String jarName, boolean deploy)
          Installs a new Jar in the database jar repository under name jarName.
static void removeJar(java.lang.String jarName, boolean undeploy)
          Removes the jar named jarName from the database jar repository.
static void replaceJar(java.lang.String urlString, java.lang.String jarName, boolean redeploy)
          Replaces the image of jar named jarName in the database jar repository.
static void setClassPath(java.lang.String schemaName, java.lang.String path)
          Define the class path to use for Java functions, triggers, and procedures that are created in the schema named schemaName This method is exposed in SQL as sqlj.set_classpath(VARCHAR, VARCHAR).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Commands

public Commands()
Method Detail

installJar

public static void installJar(java.lang.String urlString,
                              java.lang.String jarName,
                              boolean deploy)
                       throws java.sql.SQLException
Installs a new Jar in the database jar repository under name jarName. Once installed classpaths can be defined that refrences this jar. This method is exposed in SQL as sqlj.install_jar(VARCHAR, VARCHAR, BOOLEAN).

Parameters:
urlString - The location of the jar that will be installed.
jarName - The name by which the system will refer to this jar.
deploy - If set, execute install commands found in the deployment descriptor.
Throws:
java.sql.SQLException - if the jarName contains characters that are invalid or if the named jar already exists in the system.
See Also:
setClassPath(java.lang.String, java.lang.String)

replaceJar

public static void replaceJar(java.lang.String urlString,
                              java.lang.String jarName,
                              boolean redeploy)
                       throws java.sql.SQLException
Replaces the image of jar named jarName in the database jar repository. This method is exposed in SQL as sqlj.replace_jar(VARCHAR, VARCHAR, BOOLEAN).

Parameters:
urlString - The location of the jar that will be installed.
jarName - The name by which the system referes this jar.
redeploy - If set, execute remove commands found in the deployment descriptor of the old jar and install commands found in the deployment descriptor of the new jar.
Throws:
java.sql.SQLException - if the named jar cannot be found in the repository.

removeJar

public static void removeJar(java.lang.String jarName,
                             boolean undeploy)
                      throws java.sql.SQLException
Removes the jar named jarName from the database jar repository. Class path entries that references this jar will also be removed (just the entry, not the whole path). This method is exposed in SQL as sqlj.remove_jar(VARCHAR, BOOLEAN).

Parameters:
jarName - The name by which the system referes this jar.
undeploy - If set, execute remove commands found in the deployment descriptor of the jar.
Throws:
java.sql.SQLException - if the named jar cannot be found in the repository.

setClassPath

public static void setClassPath(java.lang.String schemaName,
                                java.lang.String path)
                         throws java.sql.SQLException
Define the class path to use for Java functions, triggers, and procedures that are created in the schema named schemaName This method is exposed in SQL as sqlj.set_classpath(VARCHAR, VARCHAR).

Parameters:
schemaName - Name of the schema for which this path is valid.
path - Colon separated list of names. Each name must denote the name of a jar that is present in the jar repository.
Throws:
java.sql.SQLException - If no schema can be found with the givene name, or if one or several names of the path denotes a nonexistant jar file.

getClassPath

public static java.lang.String getClassPath(java.lang.String schemaName)
                                     throws java.sql.SQLException
Return the classpath that has been defined for the schema named schemaName This method is exposed in SQL as sqlj.get_classpath(VARCHAR).

Parameters:
schemaName - Name of the schema for which this path is valid.
Returns:
The defined classpath or null if this schema has no classpath.
Throws:
java.sql.SQLException

addClassImages

public static void addClassImages(java.sql.Connection conn,
                                  int jarId,
                                  java.lang.String urlString)
                           throws java.sql.SQLException
Reads the jar found at the specified URL and stores the entries in the jar_entry table. This method must not be called directly. It must be dispatched through the Backend.addClassImages() method in order to get the needed read permission.

Parameters:
conn - The connection to use
jarId - The id used for the foreign key to the jar_repository table
urlString - The URL
Throws:
java.sql.SQLException

deployInstall

protected static void deployInstall(java.sql.Connection conn,
                                    int jarId)
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

deployRemove

protected static void deployRemove(java.sql.Connection conn,
                                   int jarId)
                            throws java.sql.SQLException
Throws:
java.sql.SQLException

assertJarName

protected static void assertJarName(java.lang.String jarName)
                             throws java.sql.SQLException
Throws an exception if the given name cannot be used as the name of a jar.

Parameters:
jarName - The naem to check.
Throws:
java.io.IOException
java.sql.SQLException

getJarId

protected static int getJarId(java.sql.Connection conn,
                              java.lang.String jarName,
                              AclId[] ownerRet)
                       throws java.sql.SQLException
Returns the primary key identifier for the given Jar.

Parameters:
conn - The connection to use for the query.
jarName - The name of the jar.
Returns:
The primary key value of the given jar or -1 if no such jar is found.
Throws:
java.sql.SQLException

getDeploymentDescriptor

protected static SQLDeploymentDescriptor getDeploymentDescriptor(java.sql.Connection conn,
                                                                 int jarId)
                                                          throws java.sql.SQLException
Throws:
java.sql.SQLException

getSchemaId

protected static Oid getSchemaId(java.sql.Connection conn,
                                 java.lang.String schemaName)
                          throws java.sql.SQLException
Returns the Oid for the given Schema.

Parameters:
conn - The connection to use for the query.
schemaName - The name of the schema.
Returns:
The Oid of the given schema or null if no such schema is found.
Throws:
java.sql.SQLException


Copyright (c) 2003, 2004, 2005 TADA AB - Taby Sweden. Distributed under the terms shown in COPYRIGHT