Search code examples
javasqlcmdvoltdb

Loading VoltDB procedures via Java classes with InProcessVoltDBServer


I am trying to load VoltDB Java procedures from methods and classes via jar with the following statement:

InProcessVoltDBServer volt = new InProcessVoltDBServer();
volt.runDDLFromString("load classes StoredProcs.jar;");

After running the jar file with java -jar I get the following error message:

SQL error while compiling query: SQL Syntax error in "LOAD CLASSES StoredProcs.jar" unexpected token: LOAD
...

It's clear to me what the message points to, but I am not certain why it's not recognizing this command?

Is this particular syntax perhaps related only to sqlcmd? If it is, is there another way to execute loading of the classes via java code?

I am using the InProcessVoltDBServer and trying to load all the DDLs and DMLs from sql script file in order to setup the environment for integration tests.

Also, I have followed this guide to setup the project in STS.

Could anyone please shed some light on what I am doing wrong here? Perhaps it's not possible to load DML (test data) like this?


Solution

  • The "LOAD CLASSES" command is only supported in sqlcmd. It is not used or supported by the lightweight InProcessVoltDBServer.

    In the guide, a java procedure is created and tested, but there isn't an explicit step to load the class. When the DDL command "CREATE PROCEDURE PARTITION ON TABLE foo COLUMN id FROM CLASS procedures.UpdateFoo;" is executed, the procedures.UpdateFoo class is already available. This may be because the procedure and test are in the same Eclipse project. If the procedure was developed separately, you would need to load the jar into the classpath for the Eclipse project where you develop the tests.

    Disclosure: I work at VoltDB.