Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I get additional information about exception?

MichaelNesterenkoJul 8 2013 — edited Oct 15 2014

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?

Comments

gimbal2

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.

unknown-7404

You can't.

MichaelNesterenko

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

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.

1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 6 2013
Added on Jul 8 2013
4 comments
475 views