ORA-00001: unique constraint (WAJAHAT.INVOICE_UQ) violated

its the exception, i want to match it with condition and take decision , but its not working

if(e1.getMessage().equals("ORA-00001: unique constraint (WAJAHAT.INVOICE_UQ) violated"))

Recommended Answers

All 12 Replies

Hello............ Any one there...................................................

Are you sure that this is exactly what the message has inside?
"ORA-00001: unique constraint (WAJAHAT.INVOICE_UQ) violated"

Try first to print the message like this for exmple:

System.out.println(">>"+e1.getMessage()+"<<");

Then you will know exactly what the message prints.

An easier solution would also be:

if ( e1.getMessage().indexOf("WAJAHAT.INVOICE_UQ")!=-1 )

Take a look at the SQLException api. There are methods to get SQL State and the Error Code, which will often provide the specific info you're wanting.

I already solved it.......

I already solved it.......

So where is solution? Why you not sharing?

commented: prevent agains down-voting +8

I already solved it......

Yes, I am aware of that.

Pardon me for mentioning additional information that I though you might find useful. String matching error messages isn't really the most robust way to isolate the nature of error conditions.

commented: i can't see reason for donw-voting +1 +8

@peter_budo @Ezzaral

hmmmm

@Majestics had, has, will have excelent question dribbling, always ask questions with agrumentations, that isn't works, isn't possible, but always without relevant code, my status was, is, and will be to my rellated questions I answered these questiuon just with respect to this community and possible futures readers,

I never imagined so much replies on a solved threads.... also -1 on asking help. ;-) Thanx mkorbel for a nice lecture. It is one of the best forum, but i think there isnt any professional who used reports with java before else i some one give me a small program to call reports from java for my previous thread responce. ;-)

@Majestics do not blame people for not giving you fast reply given the "extensive" problem description. Ezzaral tried and you slapped him with already solved
As for negative reputation, no big surprise. You ask question, come back in few hours "anybody home!?". We are not 24/7 coding service, we help when we can.

I already explained that i cant post my emotion with my message, so using word "slapped" isnt nice.... second i dont want 24/7 service but i just want a single to the point reply ..... Again i cant post my emotion with my message.

@peter_budo +1

not true at all

1/ "We are not 24/7 coding service" == We are not 24/7 SLA support

2/ "we help when we can" == we help when we want and just for our enjoy

commented: Indeed. +15

@Majestics that O.K. that only about our emotions ... :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.