Commands
Date: 2010-07-30

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.postgresql.pljava.management
Class Commands

    java.lang.Object
      org.postgresql.pljava.management.Commands

    public class Commands

extends java.lang.Object

This methods of this class are implementations of SQLJ commands.

# SQLJ functions

## install_jar

The install_jar command loads a jar file from a location appointed by an URL or a binary image that constitutes the contents of a jar file into the SQLJ jar repository. It is an error if a jar with the given name already exists in the repository.

### Usage 1

> `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

### Usage 2

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

### Parameters

> jar_image | The byte array that constitutes the contents 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 1

> `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

### Usage 2

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

### Parameters

> jar_image | The byte array that constitutes the contents 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

## add_type_mapping

The add_type_mapping defines the mapping between an SQL type and a Java class.

### Usage

> `SELECT sqlj.add_type_mapping(<sqlTypeName>, <className>);`

### Parameters

> sqlTypeName | The name of the SQL type. The name can be qualified with a schema (namespace). If the schema is omitted, it will be resolved according to the current setting of the search_path.
> className | The name of the class. The class must be found in the classpath in effect for the current schema

## drop_type_mapping

The drop_type_mapping removes the mapping between an SQL type and a Java class.

### Usage

> `SELECT sqlj.drop_type_mapping(<sqlTypeName>);`

### Parameters

> sqlTypeName | The name of the SQL type. The name can be qualified with a schema (namespace). If the schema is omitted, it will be resolved according to the current setting of the search_path.

Constructor Summary
`Commands()`

Method Summary
`static void` | `addClassImages(int jarId, java.io.InputStream urlStream)` Reads the jar found at the specified URL and stores the entries in the jar_entry table.
`static void` | `addTypeMapping(java.lang.String sqlTypeName, java.lang.String javaClassName)` Defines the mapping between an SQL type and a Java class.
`static void` | `dropTypeMapping(java.lang.String sqlTypeName)` Drops the mapping between an SQL type and a Java class.
`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)`.
`static java.lang.String` | `getCurrentSchema()`
`static void` | `installJar(byte[] image, java.lang.String jarName, boolean deploy)` Installs a new Jar in the database jar repository under name `jarName`.
`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(byte[] jarImage, java.lang.String jarName, boolean redeploy)` Replaces the image of jar named `jarName` in 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

### addClassImages

    public static void addClassImages(int jarId,
                                      java.io.InputStream urlStream)
                               throws java.sql.SQLException

  Reads the jar found at the specified URL and stores the entries in the jar_entry table.

  Parameters:
    `jarId` - The id used for the foreign key to the jar_repository table
    `urlStream` - The URL
  Throws:
    `java.sql.SQLException`

### addTypeMapping

    public static void addTypeMapping(java.lang.String sqlTypeName,
                                      java.lang.String javaClassName)
                               throws java.sql.SQLException

  Defines the mapping between an SQL type and a Java class.

  Parameters:
    `sqlTypeName` - The name of the SQL type. The name can be qualified with a schema (namespace). If the schema is omitted, it will be resolved according to the current setting of the `search_path`.
    `javaClassName` - The name of the class. The class must be found in the classpath in effect for the current schema
  Throws:
    `java.sql.SQLException`

### dropTypeMapping

    public static void dropTypeMapping(java.lang.String sqlTypeName)
                                throws java.sql.SQLException

  Drops the mapping between an SQL type and a Java class.

  Parameters:
    `sqlTypeName` - The name of the SQL type. The name can be qualified with a schema (namespace). If the schema is omitted, it will be resolved according to the current setting of the `search_path`.
  Throws:
    `java.sql.SQLException`

### 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`

### getCurrentSchema

    public static java.lang.String getCurrentSchema()
                                             throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### installJar

    public static void installJar(byte[] image,
                                  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(BYTEA, VARCHAR, BOOLEAN)`.

  Parameters:
    `image` - The byte array that constitutes the jar content.
    `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)`

### 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)`

### 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.

### replaceJar

    public static void replaceJar(byte[] jarImage,
                                  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(BYTEA, VARCHAR, BOOLEAN)`.

  Parameters:
    `jarImage` - The byte array that constitutes the jar content.
    `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.

### 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.

### 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.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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