Announcement

Collapse
No announcement yet.

Error in compiling ddl.Sql

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ghalia
    started a topic Error in compiling ddl.Sql

    Error in compiling ddl.Sql

    I'm creating new application: my ddl.sql is compiled well and I got my catalog.jar . Now I want to add a new stored procedure, so my procedure is:

    Code:
    import org.voltdb.SQLStmt;
    import org.voltdb.VoltProcedure;
    import org.voltdb.*;
    
    
    public class SELECT2 extends VoltProcedure {
    
    private final SQLStmt getUser = new SQLStmt("SELECT * FROM UC_USERS WHERE USER_NAME=? AND PASSWORD=?");
    
    /**
    * VoltDB procedures are subclass of {@link VoltProcedure} and run implicitly in transaction.
    * @param username
    
    * @param password
    
    */
    public VoltTable[] run(String name, String password) throws VoltAbortException {
    
    voltQueueSQL(getUser, name, password);
    
    return voltExecuteSQL();
    }
    }
    I create my procedure class and I add this line to my ddl.sql: "CREATE PROCEDURE FROM CLASS SELECT2 ;" When I copile my ddl I got an Error :

    Code:
    ERROR: [null]: Cannot load class for procedure: SELECT2
       caused by:
       java.lang.ClassNotFoundException: SELECT2
    ERROR: [null]: VoltDB DDL Error: "Cannot load class for procedure: SELECT2
       caused by:
       java.lang.ClassNotFoundException: SELECT2" in statement starting on lineno: 63
    ------------------------------------------
    Catalog compilation failed.
    ------------------------------------------

  • Lee
    replied
    Got it!

    Many thanks :)

    Leave a comment:


  • nshi
    replied
    Originally posted by Lee View Post
    Question: in sample.sql ddl file, do you have reference to new procedure SELECT2.class?
    Yes, you do need to reference the procedure in the schema in order to compile it into the catalog. You can follow the syntax on the following page for referencing,

    http://docs.voltdb.com/UsingVoltDB/B...clareProcs.php

    Leave a comment:


  • Lee
    replied
    Ok, thanks. I got the first part.

    Question: in sample.sql ddl file, do you have reference to new procedure SELECT2.class?

    Leave a comment:


  • nshi
    replied
    For example, to compile the catalog with the procedure SELECT2.java, you first have to compile the procedure source into Java class file,

    Code:
    javac -cp "$CLASSPATH:/opt/voltdb-ent-4.9/voltdb/*:/opt/voltdb-ent-4.9/lib/*" SELECT2.java
    Assuming that the class file is in the current working directory, you then compile the catalog with the current working directory in the classpath,

    Code:
    voltdb compile --classpath="./" -o flight.jar sample.sql

    Leave a comment:


  • Lee
    replied
    Originally posted by Ghalia View Post
    it works well, thank you so much nshi :)
    Would you mind sharing what you did, please, to compile the procedure?

    Leave a comment:


  • Ghalia
    replied
    it works well, thank you so much nshi :)

    Leave a comment:


  • Ghalia
    replied
    voltdb compile --classpath="/opt/voltdb-ent-4.9/voltdb/" -o flight.jar sample.sql

    still the same error :(

    Leave a comment:


  • nshi
    replied
    You have to also include the directory that contains the class file in the classpath when you compile the catalog.

    http://docs.voltdb.com/UsingVoltDB/B...ileCatalog.php

    Leave a comment:


  • Ghalia
    replied
    That's exactly what I have done
    javac -cp "$CLASSPATH:/opt/voltdb-ent-4.9/voltdb/*:/opt/voltdb-ent-4.9/lib/*" SELECT2.java

    Leave a comment:


  • nshi
    replied
    Hi Ghalia,

    The compiler couldn't find the procedure class because it was not in the Java classpath. You need to compile the stored procedure into Java class file, then include the class file in the classpath when you compile the catalog. You can follow the steps in the documentation. http://docs.voltdb.com/UsingVoltDB/C...ildCompileCode

    Leave a comment:

Working...
X