Discussion - the powerfull way to excellence!
Originally posted by seetharaman venkatasamy:
Try this
Discussion - the powerfull way to excellence!
Originally posted by seetharaman venkatasamy:
i gave the code for the basic of building your own exception..
if you want your own messages when the SQLException araise,then you need to build logic in your java file(use some condition)...
Discussion - the powerfull way to excellence!
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Originally posted by Rob Prime:
I strongly advise against overriding toString. Instead, create constructors that take a message:
If you pass a message (e.g. new HighLevelException("This is my message")), it will print its class name followed by ": " and the message. That's already the default toString() implementation.
If you use the constructor that only takes a Throwable it will use that Throwable's message instead.
This is how I usually create my exception classes - all four constructors (if the superclass allows it), and I can just choose which ones to use.
[ August 07, 2008: Message edited by: Rob Prime ]
Discussion - the powerfull way to excellence!
Originally posted by ram kumar:
Thanks for your advice,but did you sense me not to override toString Method.
Is it not legal ?
Now i have modified it as per my needs , is that a best practice to have that ' String msg ' static and use it.
or it has to be private static final "One exception msg for every string"
or it has to be an instance variable and all methods are non-static(in my context its all static.)
I understood that Throwable is the Exception class
like in an sqlexception !
java.sql.SQLException relates to 'Throwable var' and
table or view does not exist will be the 'String msg'
?1.Am i right with my understanding > ?
Please clarify !
Also, why do you say it Throwable instead of saying ExceptionTypeClass.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions