Skip to end of metadata
Go to start of metadata

 

NuoDB v2.0 introduces support for Java language Stored Procedures.


Stored procedures written in SQL still achieve the maximum performance boost, but Java stored procedures support a richer programming language, third-party libraries and an easy migration path from client-side code to server-side extension.


The Java method must have these features to be successfully bound to the procedure:
 

Method Typestatic
Return Typevoid
Argument #1java.Sql.Connection

Argument #2,3











For each parameter of the stored procedure there must be a parameter
in the Java method of the corresponding type as listed in this table:
SQL TypeIN ParameterINOUT or OUT Parameter
BOOLEANbooleanboolean[]
STRING, VARCHARjava.lang.Stringjava.lang.String[]
SMALLINTshortshort[]
INT, INTEGERintint[]
BIGINT, DECIMAL,
NUMBER 
longlong[]
DECIMAL (scale),
NUMBER (scale) 
java.math.BigDecimaljava.math.BigDecimal[]
FLOAT, REALfloatfloat[]
DOUBLEdoubledouble[]
DATE, DATEONLYjava.sql.Datejava.sql.Date[]
TIMESTAMPjava.sql.Timestampjava.sql.Timestamp[]
TIME, TIMEONLYjava.sql.Timejava.sql.Time[]
BLOB,CLOB,BYTES,
TEXT, VARBINARY 
byte[]byte[] []
Argument #N
(if the stored procedure
specifies the RETURNS
option)

java.sql.ResultSet[]


When the stored procedure parameter is an INOUT or OUT parameter, the Java parameter is defined as an array that at runtime will be assigned to an array of 1 element only; this way, if the Java extension code reassigns the element of the array to a different object, the caller of the method can access the modified value.


If the procedure has the RETURNS TABLE clause, the corresponding Java method must have a final java.sql.ResultSet[] argument that can be used to populate the return table. The user can also replace the object with a new ResultSet obtained by running a query.

 


Step 1  Create Java Class

For example:

 

Step 2  Compile the File

Compile the file created in Step 1 and package it into a JAR archive.

 

Step 3  Create javaclass in NuoSQL

To load the javaclass into memory, run the following command in NuoSQL (authenticated as a user with the DBA role), where myfirstjavaproc.jar is the JAR file compiled in Step 2.

For a full description of syntax and parameters, see  CREATE JAVACLASS.


Step 4  Create a NuoSQL Stored Procedure

For a full description of syntax and parameters, see CREATE PROCEDURE.


Step 5  Invoke the Java Stored Procedure

For a full description of syntax and parameters, see EXECUTE.


Step 6  Unload the Java Class

When the jar file isn't needed anymore, you can unload it unload by running the following NuoSQL command:

See DROP JAVACLASS.

 

 

 

 

 

 

  • No labels