GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.voltdb.com — @UpdateClasses Documentation@UpdateClasses@UpdateClasses — Adds and removes Java classes from the database. Synopsis@UpdateClasses byte[] JAR-file, String class-selector DescriptionThe @UpdateClasses system procedure performs two functions:
You need to compile and pack your stored procedure classes into a JAR file and load them into the database using @UpdateClasses before entering the CREATE PROCEDURE statements that define those classes as VoltDB stored procedures. Note that, for interactive use, the sqlcmd utility has two directives, load classes and remove classes, that perform these actions in separate steps. To remove classes, you specify the class names in the second parameter, the class selector. You can include multiple class selectors using a comma-separated list. You can also use Ant-style wildcards in the class specification to identify multiple classes. For example, the following command deletes all classes that are children of org.mycompany.utils as well as *.DebugHandler: sqlcmd 1> exec @UpdateClasses NULL "org.mycompany.utils.*,*.DebugHandler"; You can also use the @UpdateClasses system procedure to include reusable code that is accessed by multiple stored procedures. Reusable code includes both resource files, such as XML or other data files, as well as classes accessed by stored procedures.
Classes can be overwritten by loading a new class with the same path. Similarly, resource files can be updated by reloading a file with the same name and location. Classes can be removed using the second argument to the system procedure (or the remove classes directive). However, there is no mechanism for removing resources files other than classes once they are loaded. ExamplesThe following example compiles and packs Java stored procedures into the file myapp.jar. The example then uses @UpdateClasses to load the classes from the JAR file, then defines and partitions a stored procedure based on the uploaded classes. $ javac -cp "/opt/voltdb/voltdb/*" -d obj src/myapp/*.java $ jar cvf myapp.jar -C obj . $ sqlcmd 1> exec @UpdateClasses myapp.jar ""; 2> CREATE PROCEDURE 3> PARTITION ON TABLE Customer COLUMN CustomerID 4> FROM CLASS myapp.procedures.AddCustomer; The second example removes the class added and defined in the preceding example. Note that you must drop the procedure definition first; you cannot delete classes that are referenced by defined stored procedures. $ sqlcmd 1> DROP PROCEDURE AddCustomer; 2> exec @UpdateClasses NULL "myapp.procedures.AddCustomer"; As an alternative, the loading and removing of classes can be performed using native sqlcmd directives load classes and remove classes. So the previous tasks can be performed using the following commands: $ sqlcmd 1> load classes myapp.jar ""; 2> CREATE PROCEDURE 3> PARTITION ON TABLE Customer COLUMN CustomerID 4> FROM CLASS myapp.procedures.AddCustomer; [ . . . ] 1> DROP PROCEDURE AddCustomer; 2> remove classes "myapp.procedures.AddCustomer"; |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |