Forum Stats

  • 3,827,255 Users
  • 2,260,751 Discussions
  • 7,897,192 Comments

Discussions

How can I get additional information about exception?

MichaelNesterenko
MichaelNesterenko Member Posts: 17

I need to extract additional information from sql exception.

For example I get following exception during query execution http://ora-12899.ora-code.com/ I need to extract column name (without table name). I could do that with regular expressions, but that seems to be very fragile as message may depend on client locale and also it could change when oracle version changes.

How can I get such additional information without message parsing?

Tagged:

Answers

  • gimbal2
    gimbal2 Member Posts: 11,949 Gold Trophy

    I'm sorry, but you can't. The exception is it and in this case you're even lucky that the error contains the column name; generally the error is in the form of "it didn't work" without any kind of context-specific information in it such as a table/column name. I've been told this is because that is security-sensitive information. Which makes sense.

  • I noticed that plsql developer and sqlplus are able to get position in query string that lead to an error.

    For example output from sqlplus:

    SQL> insert into tbl (data) values('12345')

      2  /

    insert into tbl (data) values('12345')

                          *

    ERROR at line 1:

    ORA-12899: value too large for column "schmnm"."tbl"."data" (actual: 5,

    maximum: 3)

    For my current needs that would be fine. How can I get position in the query string?

  • 939520
    939520 Member Posts: 186
    edited Jul 9, 2013 8:32AM

    This might help (I haven't tried it):

    I Googled this:

       java getting more information about exception from jdbc driver

    and found this:

       http://docs.oracle.com/javase/tutorial/jdbc/basics/sqlexception.html

    Which says:

       A Cause: A SQLException instance might..... consists of one or more Trhowable objects... to navigate

       this chain of causes, recursively call the method SQLException.getCause.....

    You can probably create a simple program that duplicates the exception you get in order to test the above solution.

This discussion has been closed.