SQL Grammar Exception in Hibernate

I executed this query on HQL query editor in netbeans 6.9.1.
from teacher
But I got an error like below..
org.hibernate.exception.SQLGrammarException: could not execute query
     at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
     at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
     at org.hibernate.loader.Loader.doList(Loader.java:2223)
     at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
     at org.hibernate.loader.Loader.list(Loader.java:2099)
     at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:912)
     at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
     at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
     at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from limit 100' at line 1
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
     at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
     at com.mysql.jdbc.Util.getInstance(Util.java:381)
     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
     at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
     at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
     at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
     at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
     at org.hibernate.loader.Loader.doQuery(Loader.java:674)
     at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
     at org.hibernate.loader.Loader.doList(Loader.java:2220)
     ... 8 more
How can i fix this error.
Thanks in Advance

By fixing the HQL query that results in the query that is wrong. So step 1: trace down which HQL query is causing the misery. Step 2: turn on SQL logging to see which sql is generated for that HQL query. Step 3: figure out what is wrong. I can guess that there is something wrong with the annotations on an entity, like declaring something as nullable while it is in fact not according to the database schema. Another common culprit is using a name that is a reserved SQL keyword.
EDIT:
'from limit And the keyword name clash is the cause here. Limit is an SQL keyword in MySQL, so you can't use that as a table name.

Similar Messages

  • Unable to catch raiseerror exception from MS SQL Server Exception in hibernate

    I am using raiseerror in MS SQL Server exception to throw customized error and it is working fine in database.
    But, I am unable to catch MS SQL Server Exception in hibernate. Please find the database & java syntax below.
    SQL Server Syntax:-
        ALTER PROCEDURE [grantiumSQL].[ERROR_MESSAGE]
        @ERRMSG NVARCHAR(4000)
        AS
        BEGIN
        -- Return if there is no error information to retrieve.    
        IF ERROR_NUMBER() IS NULL    
            RETURN;    
        DECLARE     
            @ErrorMessage    NVARCHAR(4000),    
            @ErrorNumber     INT,    
            @ErrorSeverity   INT,    
            @ErrorState      INT,    
            @ErrorLine       INT,    
            @ErrorProcedure  NVARCHAR(200);    
        -- Assign variables to error-handling functions that     
        -- capture information for RAISERROR.    
        SELECT     
            @ErrorNumber = ERROR_NUMBER(),    
            @ErrorSeverity = ERROR_SEVERITY(),    
            @ErrorState = ERROR_STATE(),    
            @ErrorLine = ERROR_LINE(),    
            @ErrorProcedure = ISNULL(ERROR_PROCEDURE(), '-'),   
            @ErrorMessage = @ERRMSG
        RAISERROR     
            @ErrorMessage,    
            @ErrorSeverity,     
            1                           
            )WITH NOWAIT;
        END;
    Java Syntax:-
    public void callDeleteStoreProcedure(int workflowProjectId,String status){
      boolean shouldCommit = HibernateUtil.beginTxn();
      Session session = HibernateUtil.currentSession();
      try
      // query = session.getNamedQuery("deleteWorkflowProject_ora");
      Query callStoredProcedure = session.createSQLQuery("{PROCEDUR_NAME(?,?)}");
      callStoredProcedure.setInteger(0, prj);
      callStoredProcedure.setString(1, status);
      callStoredProcedure.executeUpdate();
         }catch (HibernateException e) {
         e.printStackTrace();
      catch (Exception e) {
          e.printStackTrace();
      HibernateUtil.commitTxn(shouldCommit);
    Thanks in advance

    HI! We have the same problem. Have you manage to resolve it?

  • PL/SQL 101 : Exception Handling

    Frequently I see questions and issues around the use of Exception/Error Handling in PL/SQL.  More often than not the issue comes from the questioners misunderstanding about how PL/SQL is constructed and executed, so I thought I'd write a small article covering the key concepts to give a clear picture of how it all hangs together. (Note: the examples are just showing examples of the exception handling structure, and should not be taken as truly valid code for ways of handling things)
    Exception Handling
    Contents
    1. Understanding Execution Blocks (part 1)
    2. Execution of the Execution Block
    3. Exceptions
    4. Understanding Execution Blocks (part 2)
    5. How to continue exection of statements after an exception
    6. User defined exceptions
    7. Line number of exception
    8. Exceptions within code within the exception block
    1. Understanding Execution Blocks (part 1)
    The first thing that one needs to understand is almost taking us back to the basics of PL/SQL... how a PL/SQL execution block is constructed.
    Essentially an execution block is made of 3 sections...
    +---------------------------+
    |    Declaration Section    |
    +---------------------------+
    |    Statements  Section    |
    +---------------------------+
    |     Exception Section     |
    +---------------------------+
    The Declaration section is the part defined between the PROCEDURE/FUNCTION header or the DECLARE keyword (for anonymous blocks) and the BEGIN keyword.  (Optional section)
    The Statements section is where your code goes and lies between the BEGIN keyword and the EXCEPTION keyword (or END keyword if there is no EXCEPTION section).  (Mandatory section)
    The Exception section is where any exception handling goes and lies between the EXCEPTION keyword at the END keyword. (Optional section)
    Example of an anonymous block...
    DECLARE
      .. declarative statements go here ..
    BEGIN
      .. code statements go here ..
    EXCEPTION
      .. exception handlers go here ..
    END;
    Example of a procedure/function block...
    [CREATE OR REPLACE] (PROCEDURE|FUNCTION) <proc or fn name> [(<parameters>)] [RETURN <datatype>] (IS|AS)
      .. declarative statements go here ..
    BEGIN
      .. code statements go here ..
    EXCEPTION
      .. exception handlers go here ..
    END;
    (Note: The same can also be done for packages, but let's keep it simple)
    2. Execution of the Execution Block
    This may seem a simple concept, but it's surprising how many people have issues showing they haven't grasped it.  When an Execution block is entered, the declaration section is processed, creating a scope of variables, types , cursors, etc. to be visible to the execution block and then execution enters into the Statements section.  Each statment in the statements section is executed in turn and when the execution completes the last statment the execution block is exited back to whatever called it.
    3. Exceptions
    Exceptions generally happen during the execution of statements in the Statements section.  When an exception happens the execution of statements jumps immediately into the exception section.  In this section we can specify what exceptions we wish to 'capture' or 'trap' and do one of the two following things...
    (Note: The exception section still has access to all the declared items in the declaration section)
    3.i) Handle the exception
    We do this when we recognise what the exception is (most likely it's something we expect to happen) and we have a means of dealing with it so that our application can continue on.
    Example...
    (without the exception handler the exception is passed back to the calling code, in this case SQL*Plus)
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_name VARCHAR2(20);
      3  begin
      4    select ename
      5    into   v_name
      6    from   emp
      7    where  empno = &empno;
      8    dbms_output.put_line(v_name);
      9* end;
    SQL> /
    Enter value for empno: 123
    old   7:   where  empno = &empno;
    new   7:   where  empno = 123;
    declare
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 4
    (with an exception handler, we capture the exception, handle it how we want to, and the calling code is happy that there is no error for it to report)
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_name VARCHAR2(20);
      3  begin
      4    select ename
      5    into   v_name
      6    from   emp
      7    where  empno = &empno;
      8    dbms_output.put_line(v_name);
      9  exception
    10    when no_data_found then
    11      dbms_output.put_line('There is no employee with this employee number.');
    12* end;
    SQL> /
    Enter value for empno: 123
    old   7:   where  empno = &empno;
    new   7:   where  empno = 123;
    There is no employee with this employee number.
    PL/SQL procedure successfully completed.
    3.ii) Raise the exception
    We do this when:-
    a) we recognise the exception, handle it but still want to let the calling code know that it happened
    b) we recognise the exception, wish to log it happened and then let the calling code deal with it
    c) we don't recognise the exception and we want the calling code to deal with it
    Example of b)
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_name VARCHAR2(20);
      3    v_empno NUMBER := &empno;
      4  begin
      5    select ename
      6    into   v_name
      7    from   emp
      8    where  empno = v_empno;
      9    dbms_output.put_line(v_name);
    10  EXCEPTION
    11    WHEN no_data_found THEN
    12      INSERT INTO sql_errors (txt)
    13      VALUES ('Search for '||v_empno||' failed.');
    14      COMMIT;
    15      RAISE;
    16* end;
    SQL> /
    Enter value for empno: 123
    old   3:   v_empno NUMBER := &empno;
    new   3:   v_empno NUMBER := 123;
    declare
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 15
    SQL> select * from sql_errors;
    TXT
    Search for 123 failed.
    SQL>
    Example of c)
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_name VARCHAR2(20);
      3    v_empno NUMBER := &empno;
      4  begin
      5    select ename
      6    into   v_name
      7    from   emp
      8    where  empno = v_empno;
      9    dbms_output.put_line(v_name);
    10  EXCEPTION
    11    WHEN no_data_found THEN
    12      INSERT INTO sql_errors (txt)
    13      VALUES ('Search for '||v_empno||' failed.');
    14      COMMIT;
    15      RAISE;
    16    WHEN others THEN
    17      RAISE;
    18* end;
    SQL> /
    Enter value for empno: 'ABC'
    old   3:   v_empno NUMBER := &empno;
    new   3:   v_empno NUMBER := 'ABC';
    declare
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    ORA-06512: at line 3
    SQL> select * from sql_errors;
    TXT
    Search for 123 failed.
    SQL>
    As you can see from the sql_errors log table, no log was written so the WHEN others exception was the exception that raised the error to the calling code (SQL*Plus)
    4. Understanding Execution Blocks (part 2)
    Ok, so now we understand the very basics of an execution block and what happens when an exception happens.  Let's take it a step further...
    Execution blocks are not just a single simple block in most cases.  Often, during our statements section we have a need to call some reusable code and we do that by calling a procedure or function.  Effectively this nests the procedure or function's code as another execution block within the current statement section so, in terms of execution, we end up with something like...
    +---------------------------------+
    |    Declaration Section          |
    +---------------------------------+
    |    Statements  Section          |
    |            .                    |
    |  +---------------------------+  |
    |  |    Declaration Section    |  |
    |  +---------------------------+  |
    |  |    Statements  Section    |  |
    |  +---------------------------+  |
    |  |     Exception Section     |  |
    |  +---------------------------+  |
    |            .                    |
    +---------------------------------+
    |     Exception Section           |
    +---------------------------------+
    Example... (Note: log_trace just writes some text to a table for tracing)
    SQL> create or replace procedure a as
      2    v_dummy NUMBER := log_trace('Procedure A''s Declaration Section');
      3  begin
      4    v_dummy := log_trace('Procedure A''s Statement Section');
      5    v_dummy := 1/0; -- cause an exception
      6  exception
      7    when others then
      8      v_dummy := log_trace('Procedure A''s Exception Section');
      9      raise;
    10  end;
    11  /
    Procedure created.
    SQL> create or replace procedure b as
      2    v_dummy NUMBER := log_trace('Procedure B''s Declaration Section');
      3  begin
      4    v_dummy := log_trace('Procedure B''s Statement Section');
      5    a; -- HERE the execution passes to the declare/statement/exception sections of A
      6  exception
      7    when others then
      8      v_dummy := log_trace('Procedure B''s Exception Section');
      9      raise;
    10  end;
    11  /
    Procedure created.
    SQL> exec b;
    BEGIN b; END;
    ERROR at line 1:
    ORA-01476: divisor is equal to zero
    ORA-06512: at "SCOTT.B", line 9
    ORA-06512: at line 1
    SQL> select * from code_trace;
    TXT
    Procedure B's Declaration Section
    Procedure B's Statement Section
    Procedure A's Declaration Section
    Procedure A's Statement Section
    Procedure A's Exception Section
    Procedure B's Exception Section
    6 rows selected.
    SQL>
    Likewise, execution blocks can be nested deeper and deeper.
    5. How to continue exection of statements after an exception
    One of the common questions asked is how to return execution to the statement after the one that created the exception and continue on.
    Well, firstly, you can only do this for statements you expect to raise an exception, such as when you want to check if there is no data found in a query.
    If you consider what's been shown above you could put any statement you expect to cause an exception inside it's own procedure or function with it's own exception section to handle the exception without raising it back to the calling code.  However, the nature of procedures and functions is really to provide a means of re-using code, so if it's a statement you only use once it seems a little silly to go creating individual procedures for these.
    Instead, you nest execution blocks directly, to give the same result as shown in the diagram at the start of part 4 of this article.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure b (p_empno IN VARCHAR2) as
      2    v_dummy NUMBER := log_trace('Procedure B''s Declaration Section');
      3  begin
      4    v_dummy := log_trace('Procedure B''s Statement Section');
      5    -- Here we start another execution block nested in the first one...
      6    declare
      7      v_dummy NUMBER := log_trace('Nested Block Declaration Section');
      8    begin
      9      v_dummy := log_trace('Nested Block Statement Section');
    10      select empno
    11        into   v_dummy
    12        from   emp
    13       where  empno = p_empno; -- Note: the parameters and variables from
                                         parent execution block are available to use!
    14    exception
    15      when no_data_found then
    16        -- This is an exception we can handle so we don't raise it
    17        v_dummy := log_trace('No employee was found');
    18        v_dummy := log_trace('Nested Block Exception Section - Exception Handled');
    19      when others then
    20        -- Other exceptions we can't handle so we raise them
    21        v_dummy := log_trace('Nested Block Exception Section - Exception Raised');
    22        raise;
    23    end;
    24    -- ...Here endeth the nested execution block
    25    -- As the nested block handled it's exception we come back to here...
    26    v_dummy := log_trace('Procedure B''s Statement Section Continued');
    27  exception
    28    when others then
    29      -- We'll only get to here if an unhandled exception was raised
    30      -- either in the nested block or in procedure b's statement section
    31      v_dummy := log_trace('Procedure B''s Exception Section');
    32      raise;
    33* end;
    SQL> /
    Procedure created.
    SQL> exec b(123);
    PL/SQL procedure successfully completed.
    SQL> select * from code_trace;
    TXT
    Procedure B's Declaration Section
    Procedure B's Statement Section
    Nested Block Declaration Section
    Nested Block Statement Section
    No employee was found
    Nested Block Exception Section - Exception Handled
    Procedure B's Statement Section Continued
    7 rows selected.
    SQL> truncate table code_trace;
    Table truncated.
    SQL> exec b('ABC');
    BEGIN b('ABC'); END;
    ERROR at line 1:
    ORA-01722: invalid number
    ORA-06512: at "SCOTT.B", line 32
    ORA-06512: at line 1
    SQL> select * from code_trace;
    TXT
    Procedure B's Declaration Section
    Procedure B's Statement Section
    Nested Block Declaration Section
    Nested Block Statement Section
    Nested Block Exception Section - Exception Raised
    Procedure B's Exception Section
    6 rows selected.
    SQL>
    You can see from this that, very simply, the code that we expected may have an exception was able to either handle the exception and return to the outer execution block to continue execution, or if an unexpected exception occurred then it was able to be raised up to the outer exception section.
    6. User defined exceptions
    There are three sorts of 'User Defined' exceptions.  There are logical situations (e.g. business logic) where, for example, certain criteria are not met to complete a task, and there are existing Oracle errors that you wish to give a name to in order to capture them in the exception section.  The third is raising your own exception messages with our own exception numbers.  Let's look at the first one...
    Let's say I have tables which detail stock availablility and reorder levels...
    SQL> select * from reorder_level;
       ITEM_ID STOCK_LEVEL
             1          20
             2          20
             3          10
             4           2
             5           2
    SQL> select * from stock;
       ITEM_ID ITEM_DESC  STOCK_LEVEL
             1 Pencils             10
             2 Pens                 2
             3 Notepads            25
             4 Stapler              5
             5 Hole Punch           3
    SQL>
    Now, our Business has told the administrative clerk to check stock levels and re-order anything that is below the re-order level, but not to hold stock of more than 4 times the re-order level for any particular item.  As an IT department we've been asked to put together an application that will automatically produce the re-order documents upon the clerks request and, because our company is so tight-ar*ed about money, they don't want to waste any paper with incorrect printouts so we have to ensure the clerk can't order things they shouldn't.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure re_order(p_item_id NUMBER, p_quantity NUMBER) is
      2    cursor cur_stock_reorder is
      3      select s.stock_level
      4            ,r.stock_level as reorder_level
      5            ,(r.stock_level*4) as reorder_limit
      6      from stock s join reorder_level r on (s.item_id = r.item_id)
      7      where s.item_id = p_item_id;
      8    --
      9    v_stock cur_stock_reorder%ROWTYPE;
    10  begin
    11    OPEN cur_stock_reorder;
    12    FETCH cur_stock_reorder INTO v_stock;
    13    IF cur_stock_reorder%NOTFOUND THEN
    14      RAISE no_data_found;
    15    END IF;
    16    CLOSE cur_stock_reorder;
    17    --
    18    IF v_stock.stock_level >= v_stock.reorder_level THEN
    19      -- Stock is not low enough to warrant an order
    20      DBMS_OUTPUT.PUT_LINE('Stock has not reached re-order level yet!');
    21    ELSE
    22      IF v_stock.stock_level + p_quantity > v_stock.reorder_limit THEN
    23        -- Required amount is over-ordering
    24        DBMS_OUTPUT.PUT_LINE('Quantity specified is too much.  Max for this item: '
                                     ||to_char(v_stock.reorder_limit-v_stock.stock_level));
    25      ELSE
    26        DBMS_OUTPUT.PUT_LINE('Order OK.  Printing Order...');
    27        -- Here goes our code to print the order
    28      END IF;
    29    END IF;
    30    --
    31  exception
    32    WHEN no_data_found THEN
    33      CLOSE cur_stock_reorder;
    34      DBMS_OUTPUT.PUT_LINE('Invalid Item ID.');
    35* end;
    SQL> /
    Procedure created.
    SQL> exec re_order(10,100);
    Invalid Item ID.
    PL/SQL procedure successfully completed.
    SQL> exec re_order(3,40);
    Stock has not reached re-order level yet!
    PL/SQL procedure successfully completed.
    SQL> exec re_order(1,100);
    Quantity specified is too much.  Max for this item: 70
    PL/SQL procedure successfully completed.
    SQL> exec re_order(2,50);
    Order OK.  Printing Order...
    PL/SQL procedure successfully completed.
    SQL>
    Ok, so that code works, but it's a bit messy with all those nested IF statements. Is there a cleaner way perhaps?  Wouldn't it be nice if we could set up our own exceptions...
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure re_order(p_item_id NUMBER, p_quantity NUMBER) is
      2    cursor cur_stock_reorder is
      3      select s.stock_level
      4            ,r.stock_level as reorder_level
      5            ,(r.stock_level*4) as reorder_limit
      6      from stock s join reorder_level r on (s.item_id = r.item_id)
      7      where s.item_id = p_item_id;
      8    --
      9    v_stock cur_stock_reorder%ROWTYPE;
    10    --
    11    -- Let's declare our own exceptions for business logic...
    12    exc_not_warranted EXCEPTION;
    13    exc_too_much      EXCEPTION;
    14  begin
    15    OPEN cur_stock_reorder;
    16    FETCH cur_stock_reorder INTO v_stock;
    17    IF cur_stock_reorder%NOTFOUND THEN
    18      RAISE no_data_found;
    19    END IF;
    20    CLOSE cur_stock_reorder;
    21    --
    22    IF v_stock.stock_level >= v_stock.reorder_level THEN
    23      -- Stock is not low enough to warrant an order
    24      RAISE exc_not_warranted;
    25    END IF;
    26    --
    27    IF v_stock.stock_level + p_quantity > v_stock.reorder_limit THEN
    28      -- Required amount is over-ordering
    29      RAISE exc_too_much;
    30    END IF;
    31    --
    32    DBMS_OUTPUT.PUT_LINE('Order OK.  Printing Order...');
    33    -- Here goes our code to print the order
    34    --
    35  exception
    36    WHEN no_data_found THEN
    37      CLOSE cur_stock_reorder;
    38      DBMS_OUTPUT.PUT_LINE('Invalid Item ID.');
    39    WHEN exc_not_warranted THEN
    40      DBMS_OUTPUT.PUT_LINE('Stock has not reached re-order level yet!');
    41    WHEN exc_too_much THEN
    42      DBMS_OUTPUT.PUT_LINE('Quantity specified is too much.  Max for this item: '
                                  ||to_char(v_stock.reorder_limit-v_stock.stock_level));
    43* end;
    SQL> /
    Procedure created.
    SQL> exec re_order(10,100);
    Invalid Item ID.
    PL/SQL procedure successfully completed.
    SQL> exec re_order(3,40);
    Stock has not reached re-order level yet!
    PL/SQL procedure successfully completed.
    SQL> exec re_order(1,100);
    Quantity specified is too much.  Max for this item: 70
    PL/SQL procedure successfully completed.
    SQL> exec re_order(2,50);
    Order OK.  Printing Order...
    PL/SQL procedure successfully completed.
    SQL>
    That's better.  And now we don't have to use all those nested IF statements and worry about it accidently getting to code that will print the order out as, once one of our user defined exceptions is raised, execution goes from the Statements section into the Exception section and all handling of errors is done in one place.
    Now for the second sort of user defined exception...
    A new requirement has come in from the Finance department who want to have details shown on the order that show a re-order 'indicator' based on the formula ((maximum allowed stock - current stock)/re-order quantity), so this needs calculating and passing to the report...
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure re_order(p_item_id NUMBER, p_quantity NUMBER) is
      2    cursor cur_stock_reorder is
      3      select s.stock_level
      4            ,r.stock_level as reorder_level
      5            ,(r.stock_level*4) as reorder_limit
      6            ,(((r.stock_level*4)-s.stock_level)/p_quantity) as finance_factor
      7      from stock s join reorder_level r on (s.item_id = r.item_id)
      8      where s.item_id = p_item_id;
      9    --
    10    v_stock cur_stock_reorder%ROWTYPE;
    11    --
    12    -- Let's declare our own exceptions for business logic...
    13    exc_not_warranted EXCEPTION;
    14    exc_too_much      EXCEPTION;
    15  begin
    16    OPEN cur_stock_reorder;
    17    FETCH cur_stock_reorder INTO v_stock;
    18    IF cur_stock_reorder%NOTFOUND THEN
    19      RAISE no_data_found;
    20    END IF;
    21    CLOSE cur_stock_reorder;
    22    --
    23    IF v_stock.stock_level >= v_stock.reorder_level THEN
    24      -- Stock is not low enough to warrant an order
    25      RAISE exc_not_warranted;
    26    END IF;
    27    --
    28    IF v_stock.stock_level + p_quantity > v_stock.reorder_limit THEN
    29      -- Required amount is over-ordering
    30      RAISE exc_too_much;
    31    END IF;
    32    --
    33    DBMS_OUTPUT.PUT_LINE('Order OK.  Printing Order...');
    34    -- Here goes our code to print the order, passing the finance_factor
    35    --
    36  exception
    37    WHEN no_data_found THEN
    38      CLOSE cur_stock_reorder;
    39      DBMS_OUTPUT.PUT_LINE('Invalid Item ID.');
    40    WHEN exc_not_warranted THEN
    41      DBMS_OUTPUT.PUT_LINE('Stock has not reached re-order level yet!');
    42    WHEN exc_too_much THEN
    43      DBMS_OUTPUT.PUT_LINE('Quantity specified is too much.  Max for this item: '
                                  ||to_char(v_stock.reorder_limit-v_stock.stock_level));
    44* end;
    SQL> /
    Procedure created.
    SQL> exec re_order(2,40);
    Order OK.  Printing Order...
    PL/SQL procedure successfully completed.
    SQL> exec re_order(2,0);
    BEGIN re_order(2,0); END;
    ERROR at line 1:
    ORA-01476: divisor is equal to zero
    ORA-06512: at "SCOTT.RE_ORDER", line 17
    ORA-06512: at line 1
    SQL>
    Hmm, there's a problem if the person specifies a re-order quantity of zero.  It raises an unhandled exception.
    Well, we could put a condition/check into our code to make sure the parameter is not zero, but again we would be wrapping our code in an IF statement and not dealing with the exception in the exception handler.
    We could do as we did before and just include a simple IF statement to check the value and raise our own user defined exception but, in this instance the error is standard Oracle error (ORA-01476) so we should be able to capture it inside the exception handler anyway... however...
    EXCEPTION
      WHEN ORA-01476 THEN
    ... is not valid.  What we need is to give this Oracle error a name.
    This is done by declaring a user defined exception as we did before and then associating that name with the error number using the PRAGMA EXCEPTION_INIT statement in the declaration section.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure re_order(p_item_id NUMBER, p_quantity NUMBER) is
      2    cursor cur_stock_reorder is
      3      select s.stock_level
      4            ,r.stock_level as reorder_level
      5            ,(r.stock_level*4) as reorder_limit
      6            ,(((r.stock_level*4)-s.stock_level)/p_quantity) as finance_factor
      7      from stock s join reorder_level r on (s.item_id = r.item_id)
      8      where s.item_id = p_item_id;
      9    --
    10    v_stock cur_stock_reorder%ROWTYPE;
    11    --
    12    -- Let's declare our own exceptions for business logic...
    13    exc_not_warranted EXCEPTION;
    14    exc_too_much      EXCEPTION;
    15    --
    16    exc_zero_quantity EXCEPTION;
    17    PRAGMA EXCEPTION_INIT(exc_zero_quantity, -1476);
    18  begin
    19    OPEN cur_stock_reorder;
    20    FETCH cur_stock_reorder INTO v_stock;
    21    IF cur_stock_reorder%NOTFOUND THEN
    22      RAISE no_data_found;
    23    END IF;
    24    CLOSE cur_stock_reorder;
    25    --
    26    IF v_stock.stock_level >= v_stock.reorder_level THEN
    27      -- Stock is not low enough to warrant an order
    28      RAISE exc_not_warranted;
    29    END IF;
    30    --
    31    IF v_stock.stock_level + p_quantity > v_stock.reorder_limit THEN
    32      -- Required amount is over-ordering
    33      RAISE exc_too_much;
    34    END IF;
    35    --
    36    DBMS_OUTPUT.PUT_LINE('Order OK.  Printing Order...');
    37    -- Here goes our code to print the order, passing the finance_factor
    38    --
    39  exception
    40    WHEN exc_zero_quantity THEN
    41      DBMS_OUTPUT.PUT_LINE('Quantity of 0 (zero) is invalid.');
    42    WHEN no_data_found THEN
    43      CLOSE cur_stock_reorder;
    44      DBMS_OUTPUT.PUT_LINE('Invalid Item ID.');
    45    WHEN exc_not_warranted THEN
    46      DBMS_OUTPUT.PUT_LINE('Stock has not reached re-order level yet!');
    47    WHEN exc_too_much THEN
    48      DBMS_OUTPUT.PUT_LINE('Quantity specified is too much.  Max for this item: '
                                  ||to_char(v_stock.reorder_limit-v_stock.stock_level));
    49* end;
    SQL> /
    Procedure created.
    SQL> exec re_order(2,0);
    Quantity of 0 (zero) is invalid.
    PL/SQL procedure successfully completed.
    SQL>
    Lastly, let's look at raising our own exceptions with our own exception numbers...
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure re_order(p_item_id NUMBER, p_quantity NUMBER) is
      2    cursor cur_stock_reorder is
      3      select s.stock_level
      4            ,r.stock_level as reorder_level
      5            ,(r.stock_level*4) as reorder_limit
      6            ,(((r.stock_level*4)-s.stock_level)/p_quantity) as finance_factor
      7      from stock s join reorder_level r on (s.item_id = r.item_id)
      8      where s.item_id = p_item_id;
      9    --
    10    v_stock cur_stock_reorder%ROWTYPE;
    11    --
    12    exc_zero_quantity EXCEPTION;
    13    PRAGMA EXCEPTION_INIT(exc_zero_quantity, -1476);
    14  begin
    15    OPEN cur_stock_reorder;
    16    FETCH cur_stock_reorder INTO v_stock;
    17    IF cur_stock_reorder%NOTFOUND THEN
    18      RAISE no_data_found;
    19    END IF;
    20    CLOSE cur_stock_reorder;
    21    --
    22    IF v_stock.stock_level >= v_stock.reorder_level THEN
    23      -- Stock is not low enough to warrant an order
    24      [b]RAISE_APPLICATION_ERROR(-20000, 'Stock has not reached re-order level yet!');[/b]
    25    END IF;
    26    --
    27    IF v_stock.stock_level + p_quantity > v_stock.reorder_limit THEN
    28      -- Required amount is over-ordering
    29     

    its nice article, have put up this one the blog
    site,Nah, I don't have time to blog, but if one of the other Ace's/Experts wants to copy it to a blog with reference back to here (and all due credit given ;)) then that's fine by me.
    I'd go for a book like "Selected articles by OTN members" or something. Does anybody have a list of links of all those mentioned articles?Just these ones I've bookmarked...
    Introduction to regular expressions ... by CD
    When your query takes too long ... by Rob van Wijk
    How to pipeline a function with a dynamic number of columns? by ascheffer
    PL/SQL 101 : Exception Handling by BluShadow

  • Java.lang.Exception: org.hibernate.AssertionFailure: scrollable result sets

    Hi All,
    I am using Oracle 11g and I am trying to delete some records from database using some GUI. In that case I am getting following error:
    java.lang.Exception: org.hibernate.AssertionFailure: scrollable result sets are not enabled. When I restart the application's service, this error is going away and deletion is working fine.
    Other related jars that I am using is as follow:
    ojdbc5.jar
    hibernate-3.0.5.jar
    I am attaching the stack trace as well:
    <log4j:event logger="org.hibernate.AssertionFailure" timestamp="1263964931355" sequenceNumber="24" level="ERROR" thread="SocketListener0-2">
    <log4j:message><![CDATA[an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)]]></log4j:message>
    <log4j:throwable><![CDATA[org.hibernate.AssertionFailure: scrollable result sets are not enabled
    at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:368)
    at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:334)
    at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:88)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1162)
    at org.hibernate.loader.Loader.scroll(Loader.java:1634)
    at org.hibernate.loader.hql.QueryLoader.scroll(QueryLoader.java:443)
    at org.hibernate.hql.ast.QueryTranslatorImpl.scroll(QueryTranslatorImpl.java:291)
    at org.hibernate.impl.SessionImpl.scroll(SessionImpl.java:960)
    at org.hibernate.impl.QueryImpl.scroll(QueryImpl.java:62)
    at com.sample.persistence.WorklistItemDAO.purge(WorklistItemDAO.java:145)
    at com.sample.server.worklistmanager.WorklistManager.purge(WorklistManager.java:695)
    at com.sample.server.webservices.CCGPIWorklistHandler.purge(CCGPIWorklistHandler.java:329)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.xmlrpc.Invoker.execute(Invoker.java:130)
    at org.apache.xmlrpc.XmlRpcWorker.invokeHandler(XmlRpcWorker.java:84)
    at org.apache.xmlrpc.XmlRpcWorker.execute(XmlRpcWorker.java:146)
    at org.apache.xmlrpc.XmlRpcServer.execute(XmlRpcServer.java:139)
    at org.apache.xmlrpc.XmlRpcServer.execute(XmlRpcServer.java:114)
    at com.sample.server.webservices.XmlRpcServlet.service(XmlRpcServlet.java:63)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
    at org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:666)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
    at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
    at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
    at org.mortbay.http.HttpServer.service(HttpServer.java:909)
    at org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
    at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:982)
    at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
    at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
    at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
    at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
    ]]></log4j:throwable>
    </log4j:event>
    Thanks
    Shiv

    Hi All,
    anybody got a chance to look into it?
    --Shiv                                                                                                                                                                                                       

  • Oracle 's SQL grammar

    I want to find documents about Oracle's SQL grammar (in BNF) in order to write a translator that translate SQL commands (initialy SELECT, INSERT, DELETE, UPDATE commands) from Oracle to MS SQL Server. Who can help me?

    You can't find them in one location all together.
    But you can try the following.
    In this location
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/langelems.htm#sthref2447
    you can find all PL/SQL language elements (SQL excluded).
    Now, download the whole Oracle 10g documentation and try to track down the directory on your hard disk where the htm-files for this location are stored:
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/img_text/
    It seems like all of them are are stored here, every language element in a htm-file of its own. It is not possible to open this directory in the browser.
    Perhaps this helps,
    Xenofon

  • PL/SQL Parameterized Exceptions?

    I develop on the Oracle EBS platform and so I have to develop using multiple general purpose programming languages.  Mainly PL/SQL and Java but we also use Ruby and Korn Shell for example.  One thing I have trouble with in PL/SQL is exception handling.  I would really like to be able to provide additional information in an Exception in PL/SQL but don't know how to do so.  One way would be to define an exception with parameters.  Thus providing some slots to stick information into when raising an exception and then using the information when the exception is caught.  I've used raise_application_error that provides slots for a number and text but that's not really my idea of a good solution to this issue.  I like the Ruby Exception object approach myself that allows you to define the slots yourself via sub-classing an Exception class.  I've used OO PL/SQL successfully in certain solutions and I know it works but there are some serious shortcomings that make OO PL/SQL a bit of a no-mans land in my opinion so I think an Exception class in PL/SQL is probably not the way to go at this point but I could be wrong.  So I thought how about defining exceptions with parameters much like a procedure or function.  Is this coming or are there ways to provide additional information in an exception that you have used successfully?
    Thank you

    I got an error when I compiled your procedure
    SQL> create or replace procedure myexception (v  number) is
      2    v1   emp.empno%type;
      3    begin
      4    select empno into v1 from emp where empno=v;
      5    exception when no_data_found then
      6    dbms_output.put_line('No data found');
      7    Do first thing----
      8    when too_many_rows then
      9    dbms_output.put_line('Too many rows');
    10    Do second thing----
    11    when others then
    12    --Do third thing
    13    end;
    14    .
    15   /
    Warning: Procedure created with compilation errors.
    SQL> sho err
    Errors for PROCEDURE MYEXCEPTION:
    LINE/COL ERROR
    13/3     PLS-00103: Encountered the symbol "END" when expecting one of the
             following:
             begin case declare exit for goto if loop mod null pragma
             raise return select update while with <an identifier>
             <a double-quoted delimited-identifier> <a bind variable> <<
             close current delete fetch lock insert open rollback
             savepoint set sql execute commit forall merge pipe
    SQL> create or replace procedure myexception (v  number) is
      2    v1   emp.empno%type;
      3  begin
      4    select empno into v1 from emp where empno=v;
      5  exception when no_data_found then
      6    dbms_output.put_line('No data found');
      7    Do first thing----
      8  when too_many_rows then
      9    dbms_output.put_line('Too many rows');
    10    Do second thing----
    11  when others then
    12    --Do third thing
    13 dbms_output.put_line(SQLERRM);
    14  end;
    15  /
    Procedure created.
    SQL>

  • Complete plsql and sql grammars

    Hi Guys,
    Does anyone know where to get the complet PLSQL and SQL grammars?
    The one I found is outdated.....

    Unfortunately, the SQL (and PL/SQL) reference are probably the closest you're going to get (at least from Oracle). And that documentation is designed to be human readable, so it includes comments and explanations in addition to the bare syntax. You could, of course, cut and paste the BNF syntax diagrams from each page into a single document, but that's probably a rather laborious and error-prone process.
    If you're just interested in ANSI standard SQL, you might look to see whether the ANSI standard document includes a single syntax tree.
    I still, though, come back to the question of why. The documentation Oracle provides seems quite human readable to me-- I'd be hard pressed to envision a need for a SQL programmer to have a single document that contains just BNF diagrams for every SQL statement without explanation or discussion. The only people I could imagine wanting this would be writing a SQL (or PL/SQL) parser, which is virtually guaranteed not to match Oracle's real SQL (or PL/SQL) parsers, particularly given the frequency that the real parsers change.
    Justin

  • Obiee server SQL throw exception :ORA-29275

    The obiee server throws oracle exception: ORA-29275 while execute in the sql in the bidw , the sql results have Chinese characters
    I have try to copy the sql to query from Jdeveloper adn SQL developer , the sql can run and no exception so does it the NSL_LANG issue in the obiee server side ?
    I also have try to set the NSL_LANG as AMERICAN_AMERICA.AL32UTF8 and AMERICAN_AMERICA.UTF8 , and they seems not worked!
    Odbc driver returned an error (SQLExecDirectW).
    Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 17001] Oracle Error code: 29275, message: ORA-29275: partial multibyte character at OCI call OCIStmtFetch. [nQSError: 17012] Bulk fetch failed. (HY000)

    Any one can help?

  • Mac OS X SQL Developer Exception initializing 'oracle.dbtools.raptorDBAddin

    I can't get the DB Connnection wizard to startup, probably because Raptor didn't initialize properly. I've cleaned out ~/.sqldeveloper, I've added the
    appropriate NLS lines to sqldeveloper.conf:
    AddVMOption -Duser.language=en
    AddVMOption -Duser.country=US
    AddVMOption -Duser.region=US
    and I'm using the latest download sqldeveloper-5783-macosx.tar.gz.
    Java is:
    java -version
    java version "1.6.0_07"
    Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153)
    Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)
    Mac OS Version is 10.5.6 on a MacBook Pro.
    I also have Instant_client_10_2 installed. Perhaps the libraries from this are interfering in some way?
    Can anyone please help?
    Exception stack follows. This stack was displayed in a terminal window:
    cd /Applications/SQLDeveloper.app/Contents/MacOS
    bash ./sqldeveloper.sh
    Exception initializing 'oracle.dbtools.raptor.RaptorDBAddin' in extension 'Oracle SQL Developer': java.lang.NoSuchMethodError: oracle.i18n.util.GDKOracleMetaData.getDataPath()Ljava/lang/String;
    at oracle.i18n.text.OraBoot.&lt;clinit&gt;(OraBoot.java:72)
    at oracle.i18n.util.OraLocaleInfo.&lt;init&gt;(OraLocaleInfo.java:197)
    at oracle.i18n.util.OraLocaleInfo.getInstance(OraLocaleInfo.java:272)
    at oracle.dbtools.raptor.config.DBConfig.&lt;clinit&gt;(DBConfig.java:286)
    at oracle.dbtools.raptor.RaptorDBAddin.initialize(RaptorDBAddin.java:111)
    at oracle.ideimpl.extension.AddinManagerImpl.initializeAddin(AddinManagerImpl.java:405)
    at oracle.ideimpl.extension.AddinManagerImpl.initializeAddins(AddinManagerImpl.java:214)
    at oracle.ideimpl.extension.AddinManagerImpl.initProductAndUserAddins(AddinManagerImpl.java:128)
    at oracle.ide.IdeCore.initProductAndUserAddins(IdeCore.java:1804)
    at oracle.ide.IdeCore.startupImpl(IdeCore.java:1481)
    at oracle.ide.Ide.startup(Ide.java:662)
    at oracle.ideimpl.DefaultIdeStarter.startIde(DefaultIdeStarter.java:35)
    at oracle.ideimpl.Main.start(Main.java:110)
    at oracle.ideimpl.Main.main(Main.java:72)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at oracle.ide.boot.PCLMain.callMain(PCLMain.java:66)
    at oracle.ide.boot.PCLMain.main(PCLMain.java:58)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at oracle.classloader.util.MainClass.invoke(MainClass.java:128)
    at oracle.ide.boot.IdeLauncher.bootClassLoadersAndMain(IdeLauncher.java:190)
    at oracle.ide.boot.IdeLauncher.launchImpl(IdeLauncher.java:90)
    at oracle.ide.boot.IdeLauncher.launch(IdeLauncher.java:66)
    at oracle.ide.boot.IdeLauncher.main(IdeLauncher.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at oracle.ide.boot.Launcher.invokeMain(Launcher.java:729)
    at oracle.ide.boot.Launcher.launchImpl(Launcher.java:115)
    at oracle.ide.boot.Launcher.launch(Launcher.java:68)
    at oracle.ide.boot.Launcher.main(Launcher.java:57)
    Exception initializing 'oracle.dbtools.raptor.standalone.RaptorStandaloneAddin' in extension 'Oracle SQL Developer Extras': java.lang.NoClassDefFoundError: Could not initialize class oracle.dbtools.raptor.config.DBConfig
    at oracle.dbtools.raptor.utils.URLChooserShortcuts.&lt;clinit&gt;(URLChooserShortcuts.java:39)
    at oracle.dbtools.raptor.standalone.RaptorStandaloneAddin.initialize(RaptorStandaloneAddin.java:182)
    at oracle.ideimpl.extension.AddinManagerImpl.initializeAddin(AddinManagerImpl.java:405)
    at oracle.ideimpl.extension.AddinManagerImpl.initializeAddins(AddinManagerImpl.java:214)
    at oracle.ideimpl.extension.AddinManagerImpl.initProductAndUserAddins(AddinManagerImpl.java:128)
    at oracle.ide.IdeCore.initProductAndUserAddins(IdeCore.java:1804)
    at oracle.ide.IdeCore.startupImpl(IdeCore.java:1481)
    at oracle.ide.Ide.startup(Ide.java:662)
    at oracle.ideimpl.DefaultIdeStarter.startIde(DefaultIdeStarter.java:35)
    at oracle.ideimpl.Main.start(Main.java:110)
    at oracle.ideimpl.Main.main(Main.java:72)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at oracle.ide.boot.PCLMain.callMain(PCLMain.java:66)
    at oracle.ide.boot.PCLMain.main(PCLMain.java:58)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at oracle.classloader.util.MainClass.invoke(MainClass.java:128)
    at oracle.ide.boot.IdeLauncher.bootClassLoadersAndMain(IdeLauncher.java:190)
    at oracle.ide.boot.IdeLauncher.launchImpl(IdeLauncher.java:90)
    at oracle.ide.boot.IdeLauncher.launch(IdeLauncher.java:66)
    at oracle.ide.boot.IdeLauncher.main(IdeLauncher.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at oracle.ide.boot.Launcher.invokeMain(Launcher.java:729)
    at oracle.ide.boot.Launcher.launchImpl(Launcher.java:115)
    at oracle.ide.boot.Launcher.launch(Launcher.java:68)
    at oracle.ide.boot.Launcher.main(Launcher.java:57)
    Exception in thread "XML Action Loader" java.lang.NoClassDefFoundError: Could not initialize class oracle.dbtools.raptor.config.DBConfig
    at oracle.dbtools.raptor.dialogs.actions.XMLBasedObjectAction$1$1.run(XMLBasedObjectAction.java:148)
    Exception in thread "EditorLoader" java.lang.NoClassDefFoundError: Could not initialize class oracle.dbtools.raptor.config.DBConfig
    at oracle.dbtools.raptor.oviewer.base.ViewerAddin.loadXMLEditors(ViewerAddin.java:235)
    at oracle.dbtools.raptor.oviewer.base.ViewerAddin$1$1.run(ViewerAddin.java:142)
    at java.lang.Thread.run(Thread.java:637)
    tethys:MacOS mbs$

    Setting ORACLE_HOME as below made no difference in the exception stack (same as reported above).
    $ echo $ORACLE_HOME
    /Applications/SQLDeveloper.app/Contents/Resources/sqldeveloper
    ls $ORACLE_HOME
    BC4J               jdbc               raptor_image.jpg     sqldeveloper
    dvt               jdev               rdbms               sqldeveloper.sh
    icon.png          jlib               relnotes.html          timingframework
    ide               lib               sqlcli
    j2ee               otn_new.css          sqlcli.bat
    Was this the correct ORACLE_HOME value to try?
    Does anyone know the names and locations of the libraries that are likely to be conflicting (if that
    is indeed the problem...)?

  • SQL Loader Exception while loading Partitioned table

    Hi,
    I have a table EMP and it has year wise partitions created based on creation_date column.
    Now, I using SQL Loader to load bulk data using Java Program. But I am getting SQLLoader Exception. When I drop partition on the table, same code is working fine.
    Do I need to do anything extra for the partitioned table?
    Please help me.
    Thanks

    SQL Loader should produce a log file with an error code(s) in it. Check for that.

  • How to handle sql error exception in view object

    Guys,
             I have view object (with rows fetched from a sql query).
    Say the query in the VO looks like this..
    select plsql_fun(c) from dual
    (Note : the plsql function in the above query can throw an exception in some cases)
    when the plsql function throws a exception, we get sql exception  (oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation)
    Is there any way i can catch this exception and return -1 in the view object...
    Thanks in advance.

    Check out http://www.oracle.com/technetwork/issue-archive/2013/13-mar/o23adf-1897193.html
    Have you tried to surround hte executeQuery  with a try catch block?
    Timo

  • Getting Exception  in hibernate (ResolvableNode)

    Hi
    i am using hibernate and update the table throw the Hibernate but i am getting un excepted Exception
    "java.lang.ClassCastException: org.hibernate.hql.ast.SqlNode cannot be cast to org.hibernate.hql.ast.ResolvableNode"
    for executed below method
    public boolean updateBackupFiles(String filename, int count) throws DBException {
    String updateHQL = "update BackupFile set count = :count where filename = :filename";
    boolean flag = false;
    int rs=0;
    Session session = sessionFactory.openSession();
    Transaction tr = null;
    try {
    tr = session.beginTransaction();
    Query query = session.createQuery(updateHQL);
    query.setInteger("count",count);
    query.setString("filename", filename);
    rs = query.executeUpdate();
    if (rs > 0) {
    flag = true;
    if(rs % 20==0){
    session.flush();
    tr.commit();
    } catch (Exception sqle) {
    sqle.printStackTrace();
    throw new DBException("ERROR: getUpdateBackupfiles1()", sqle);
    } finally {
    session.close();
    return flag;
    please Reply soon
    Thanks & regard
    Mudit kumar Dwivedi
    Hightech infoystem Jabalpur Pvt Lmt.

    Hi,
    I do not think this is the right forum to deal with Hibernate; post it at www.hibernate.org in the user forum so that you can get better help
    Regards,
    Alan Mehio
    London,UK

  • Abot oracle.sql.opaque exception

    Wheen I run a program which is retreiving xmltype data from databse using a application then it works fine. But If I use jsp for same a deploy it on OC4jJ server it fgives exception at this line
    xml = (XMLType)resultSet.getObject(1);
    Excpeuin is ClassCasrtException: oracle.sql.OPAQUE
    Please expalon. Methis is given below it works fine with application
    public Vector doSelect (String keywords[]) throws Exception
    //System.out.println("++++ Start of doSelect() method ++++");
    // String SQLTEXT="SELECT extract(warehouse_spec,'/"+ str + "') as XMLDocument FROM WAREHOUSES";
    /* select extract (value(t),'/VideoSubIndex')
    * from mastersvideo x,TABLE (xmlsequence (
    * extract (x.vindex,'/VideoIndexes/VideoSubIndex'))) t
    * where existnode(value(t),'/VideoSubIndex[Transcription="So basically"]')=1
    // String SQLTEXT="SELECT extract(x.vindex,'/VideoIndexes/VideoSubIndex/Transcription') as XMLDocument FROM mastersvideo x"+
    // " where existsnode(x.vindex,'/VideoIndexes/VideoSubIndex[Transcription=\"So basically\"]')=1";
    String SQLTEXT="select extract (value(t),'/VideoSubIndex') from mastersvideo x,TABLE (xmlsequence (extract (x.vindex,'/VideoIndexes/VideoSubIndex'))) t where existsnode(value(t),'/VideoSubIndex[Transcription=\"So basically\"]')=1";
    // String SQLTEXT="select extract (value(t),'/VideoSubIndex') from mastersvideo x,TABLE (xmlsequence (extract (x.vindex,'/VideoIndexes/VideoSubIndex'))) t where existsnode(value(t),'/VideoSubIndex[ora:contains(Transcription,\"way\")>0]','xmlns:ora=\"http://xmlns.oracle.com/xdb\"')=1";
    //keywords="sql";
    //description="basically";
    for(int i=0;i<keywords.length;i++)
    System.out.println("KeyWords Received"+keywords);
    String SQLTEXT=null;
    if (keywords.length>0)
    SQLTEXT="select extract (value(t),'/VideoSubIndex') from mastersvideo x,TABLE (xmlsequence (extract (x.vindex,'/VideoIndexes/VideoSubIndex'))) t where existsnode(value(t),'/VideoSubIndex[ora:contains(@KeyTerm,\""+keywords[0]+"\")>0]','xmlns:ora=\"http://xmlns.oracle.com/xdb\"')=1"+
    " OR existsnode(value(t),'/VideoSubIndex[ora:contains(Transcription,\""+keywords[0]+"\")>0]','xmlns:ora=\"http://xmlns.oracle.com/xdb\"')=1";
    for(int i=1;i<keywords.length;i++)
    System.out.println("Value of i "+i+" And Value Here"+keywords[i]);
    SQLTEXT+=" OR existsnode(value(t),'/VideoSubIndex[ora:contains(@KeyTerm,\""+keywords[i]+"\")>0]','xmlns:ora=\"http://xmlns.oracle.com/xdb\"')=1"+
    " OR existsnode(value(t),'/VideoSubIndex[ora:contains(Transcription,\""+keywords[i]+"\")>0]','xmlns:ora=\"http://xmlns.oracle.com/xdb\"')=1";
    // SQLTEXT+=
    // Running Query
    // String SQLTEXT="select extract (value(t),'/VideoSubIndex') from mastersvideo x,TABLE (xmlsequence (extract (x.vindex,'/VideoIndexes/VideoSubIndex'))) t where existsnode(value(t),'/VideoSubIndex[ora:contains(@KeyTerm,\""+keywords[0]+"\")>0]','xmlns:ora=\"http://xmlns.oracle.com/xdb\"')=1"+
    // " OR existsnode(value(t),'/VideoSubIndex[ora:contains(Transcription,\""+keywords[0]+"\")>0]','xmlns:ora=\"http://xmlns.oracle.com/xdb\"')=1";
    //System.out.println(SQLTEXT);
    OraclePreparedStatement sqlStatement = null;
    //OracleResultSet resultSet = null;
    ResultSet resultSet = null;
    oracle.xdb.XMLType xml = null;
    try
    System.out.println("SQL := " + SQLTEXT);
    sqlStatement = (OraclePreparedStatement) getConnection("scott","tiger").prepareStatement(SQLTEXT);
    System.out.println("+++++ OraclePreparedStatement created +++++");
    // resultSet = (OracleResultSet) sqlStatement.executeQuery();
    resultSet = sqlStatement.executeQuery();
    System.out.println("***** Query Executed *****");
    // return resultSet;
    Vector resVector=new Vector();
    while(resultSet.next())
    System.out.println("Hello Miss World");
    xml = (XMLType)resultSet.getObject(1);
    //System.out.println("Hello World");
    resVector.add(xml);
    // xml.get
    System.out.println(xml.getStringVal());
    //System.out.println("Hello Miss World");
    System.out.println("Vector size is "+resVector.size());
    return resVector;
    catch(NullPointerException npe)
    catch (SQLException SQLe)
    if (sqlStatement != null)
    sqlStatement.close();
    throw SQLe;
    /*if(resultSet!=null)
    resultSet.close();
    System.out.println("**** Resultset closed ****");
    if(sqlStatement!=null)
    sqlStatement.close();
    System.out.println("**** Resultset closed ****");
    System.out.println("### Returning Vector ###");
    return null;
    } // End of Function doSelect()

    I believe the 9.2 XDK requires the use of the 9.2 JDBC drivers.
    In general, later versions of the JDBC driver will work with older versions of the database, but not vice versa. The 8.1.7 JDBC drivers won't necessarily work with a 9.2 database, but the 9.2 JDBC drivers will work with an 8.1.7 database.
    Justin

  • MS SQL Server Exception Error

    I am working on a project that sends information to MS SQL Server. When submitting information to the database, I am using a stored procedure that I wrote. When I submit information to the database, I get this exception:
    java.sql.SQLException: No ResultSet was produced.
    Here is the code for the stored procedure:
    CREATE PROCEDURE insertcusip(
    @IssueName varchar(20),
    @DDate datetime,
    @Cusip2 varchar(15) )
    as
    insert into IssueCusip(
    IssuerName,
    DatedDate,
    Cusip )
    values(
    @IssueName,
    @DDate,
    @Cusip2)
    Here is the code where the information is going into the database:
    try
    // query for insert
    String sql = "EXECUTE insertcusip '"+ IssueNametextField.getText() + "'" + "," + "'" + DatedDatetextField.getText() + "'" + "," + "'" + CusiptextField.getText() + "'";
              System.out.println(sql);
                   stmt11.executeQuery(sql);
                   //ResultSet rset11 = stmt11.executeQuery(sql);
                   //rset11.close();
                   catch(Exception ex)
                        System.out.println(ex);
    But when I check in the database, the information was submitted. Does anyone know where the exception could be coming from?

    probably this line
    stmt11.executeQuery(sql);
    as this returns a resultset but you do not need one.
    just call this instead and see if it fixes it.
    stmt11.execute(sql);

  • Sybase ESP java sdk, SQL parser exception for all queries

    Hi,
    I am new to Sybase ESP java sdk. Trying to use sdk projection subscription, but getting for all the queries including blank string:-
    com.sybase.esp.sdk.exception.ProjectErrorException: SQL parsing error
    at com.sybase.esp.sdk.impl.SubscriberImplV3.doSubscribe(Unknown Source)
    at com.sybase.esp.sdk.impl.SubscriberImpl.subscribeSql(Unknown Source)
    My Example code :-
    Credentials creds = new Credentials.Builder(Credentials.Type.USER_PASSWORD).setUser("user").setPassword("pwd").create();
      Project project = s_sdk.getProject(uri, creds);
      project.connect(WAIT_TIME_60000_MS);
      Subscriber subscriber = project.createSubscriber();
      //subscriber.subscribeStream("Trades");
      subscriber.connect();
                    subscriber.subscribeSql("select UserMaxCpu from wSBW912");
    I am new to sdk and not sure what I am doing wrong here, please suggest.
    Thanks,
    Venkatesh

    The problem you're experiencing is due to your JNDI configuration not matching the JavaDB database where you created the tables.
    If you look at the config for DerbyPool in the Admin Console, you'll see that DerbyPool points to:
    jdbc:derby://localhost:1527/sun-appserv-samples
    In the Admin Console click Resources->Connection Pools->DerbyPool, then click Additional Properties (9.1) or look at the page (9.0).
    You can either modify DerbyPool's config to point to:
    jdbc:derby://localhost:1527/BookDB
    Or you can create the tables in sun-appserv-samples. The create-tables ant task included with the Java EE 5 Tutorial will create the tables in the correct database.
    -ian

Maybe you are looking for