Makes Java classes available for use within a database.
INSTALL JAVA [ install-mode ] [ JAR jar-name ] FROM source
{ NEW | UPDATE }
{ FILE filename | URL url-value }
The following statement installs the user-created Java class named Demo by providing the filename and location of the class.
INSTALL JAVA NEW FROM FILE 'D:\JavaClass\Demo.class'
After installation, the class is referenced using its name. It's original file path location is no longer used. For example, the following statement uses the class installed in the previous statement.
CREATE VARIABLE d Demo
If the Demo class was a member of the package sybase.work, the fully qualified name of the class must be used, for example:
CREATE VARIABLE d sybase.work.Demo
The following statement installs all the classes contained in a zip file, and associates them within the database with a JAR file name.
INSTALL JAVA JAR 'Widgets' FROM FILE 'C:\Jars\Widget.zip'
Again, the location of the zip file is not retained and classes must be reference using the fully qualified class name (package name and class name). The zip file must be an uncompressed Jar file.
Install mode Specifying an install mode of NEW requires that the referenced Java classes are new classes, rather than updates of currently installed classes. An error occurs if a class with the same name exists in the database and the NEW install mode is used.
Specifying UPDATE specifies that the referenced Java classes may include replacements for Java classes already installed in the given database.
Connection must be dropped for update to take effect Updating a Java class installed in a database takes effect immediately. However, the connection used to execute the INSTALL JAVA UPDATE statement has access only to the older version of the Java class until the connection is dropped.
A client application executing this statement should drop the database connection used to execute the statement and reconnect in order to get access to the latest version.
This applies to the DBISQL utility also. If you update a Java class by executing the INSTALL statement from DBISQL, the new version is not available until you disconnect from the database engine or server and reconnect.
If install mode is omitted, then the default is NEW.
JAR If this is specified, then the file-name or text-pointer must designate a jar file or a column containing a jar. Jar files typically have extensions of .jar or .zip.
Installed jar and zip files can be compressed or uncompressed. However, jar files produced by the Sun JDK jar utility are not supported. Files produced by other zip utilities are supported.
If the JAR option is specified, then the jar is retained as a jar after the classes that it contains have been installed. That jar is the associated jar of each of those classes. The set of jars installed in a database with the JAR option are called the retained jars of the database.
Retained jars are referenced in INSTALL and REMOVE statements. Retained jars have no effect on other uses of Java-SQL classes. Retained jars are used by the SQL system for requests by other systems for the class associated with given data. If a requested class has an associated jar, then the SQL system can supply that jar, rather than the individual class.
The jar-name is a character string value of length up to 255 bytes. The jar-name is used to identify the retained jar in subsequent INSTALL UPDATE and REMOVE statements.
source Specifies the location of the Java class(es) to be installed.
The formats supported for file-name include fully qualified file names, such as 'c:\libs\jarname.jar' and '/usr/u/libs/jarname.jar', and relative file names, which are relative to the current working directory of the database server.
The filename must identify either a class file, or a jar file.
The class definition for each class is loaded by each connection's VM the first time that class is used. When you INSTALL a class, the VM on your connection is implicitly restarted. Therefore, you have immediate access to the new class, whether the INSTALL has an install-mode of NEW or UPDATE.
For other connections, the new class is loaded the next time a VM accesses the class for the first time. If the class is already loaded by a VM, that connection does not see the new class until the VM is restarted for that connection (for example, with a STOP JAVA and START JAVA).
DBA permissions are required to execute the INSTALL statement.
All installed classes can be referenced in any way by any user.