1

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?

Marko Jovanov
  • 418
  • 10
  • 25

1 Answers1

1

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.

BenjaminBallard
  • 1,482
  • 12
  • 11
  • Hi Benjamin, thank you for the swift response. That did the trick, thank you! Also, one not so obvious part - I was able to load both DDL and DML file with ``volt.runDDLFromPath``, they just had to be separated in two .sql files. – Marko Jovanov Feb 21 '19 at 16:04
  • Thanks, I never tried that, but it's good to know. Much easier to use a dml script than to wrap each statement in java procedure calls. – BenjaminBallard Feb 21 '19 at 21:03
  • Is this supported in older versions of voltdb? I get "> load classes test.jar; Unexpected Ad Hoc Planning Error: java.lang.RuntimeException: Error compiling query: org.voltdb.planner.PlanningErrorException: SQL Syntax error in "load classes test.jar" unexpected token: LOAD" when using sqlcmd. – Lieuwe Aug 09 '19 at 14:59
  • load classes has been supported since v5.1, so quite a while. – BenjaminBallard Aug 17 '19 at 01:05