Announcement

Collapse
No announcement yet.

Error in compiling ddl.Sql

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

  • 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.
    ------------------------------------------

  • #2
    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
    Ning

    Comment


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

      Comment


      • #4
        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
        Ning

        Comment


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

          still the same error :(

          Comment


          • #6
            it works well, thank you so much nshi :)

            Comment


            • #7
              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?

              Comment


              • #8
                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
                Ning

                Comment


                • #9
                  Ok, thanks. I got the first part.

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

                  Comment


                  • #10
                    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
                    Ning

                    Comment


                    • #11
                      Got it!

                      Many thanks :)

                      Comment

                      Working...
                      X