Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Catch the very syntax error OUTSIDE SQL*Plus

Re: Catch the very syntax error OUTSIDE SQL*Plus

From: DStevens <dstevens_at_navidec.com>
Date: Wed, 28 Nov 2001 09:04:41 -0700
Message-ID: <3C050B19.445CDC5@navidec.com>


Yes, there is a way. Check the JDBC documentation. Basically, you can find the error number and text in the CATCH portion of your try/catch block.
Example:
 catch(SQLException ex)

     {
      results.addElement("\n--- SQLException caught ---\n");
     while (ex != null)
      {
        results.addElement("Message:   " + ex.getMessage ());
        results.addElement("SQLState:  " + ex.getSQLState ());
        results.addElement("ErrorCode: " + ex.getErrorCode ());
        ex = ex.getNextException();
      } // End of While Loop for Exception printing
     } // End of catch for SQL exception


Sri wrote:

> Hi,
> I'd like to know if there's a way of trapping
> the error you've made when you run a SQL statement,
> not only the SQL error number/text. You know SQL*Plus
> puts a mark (a '*') below the string that caused the
> error:
> > select count(1) from iit.giv_comtr
> > *
> > ERROR at line 1 :
> > ORA-00942: table or view does not exist
>
> This is what I'd like to be able to catch and to deal
> with, cause I'm performing my connections from Java...
>
> Is it specific to the SQL*Plus software, or is there a
> way of getting these very errors causes ?
>
> Thanks for any idea/help.
> Regs,
> Sri
Received on Wed Nov 28 2001 - 10:04:41 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US