Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling SQLException

 
arfeen khan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way to fetch the column name name for which SQL exception occurred?

For example a table MyTable is defined as --
UID NOT NULL NUMBER
AGE NUMBER

Now if issue following insert it will raise ORA-01722-
INSERT INTO testchild VALUES(5, 'tes')
as AGE column expects a number, but we are providing a string.
So i want in my JDBC program to get for which column (here age) this error occurred.

Please help on this.
 
Rakesh Keerthi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Afreen,

could you please post the code that you have tried so far?

Thanks
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, Oracle doesn't report name of the column that "caused" the exception, most probably because this exception could generally occur in any expression, even in expressions that relate either to none, or several columns at once. I don't know of any way to overcome this.

Edit: you should carefully avoid implicit conversions in your code; if you do, you won't encounter this exception. When searching for a bug lurking in the code, you could employ either extensive logging or debugging to nab (and crush! ) the bug.
 
arfeen khan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for posting the reply.
Though there was not a exact answer, but some how satisfying response.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic