aspose file tools*
The moose likes Beginning Java and the fly likes Sql Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Sql Exception" Watch "Sql Exception" New topic
Author

Sql Exception

Natesan Prabhakaran
Ranch Hand

Joined: Jul 11, 2006
Posts: 47
Hi..
Is sqlException is RunTime Exception or CompileTime Exception., I know it is CompileTime Exception, then how it is working while compiletime., its confusing me. Thanks.

Regards
Prabhakaran.N


Regards,
Prabhakaran.N
subodh gupta
Ranch Hand

Joined: Jul 23, 2007
Posts: 203
Hi

Can you make the situation more clear by asking the specific question.


http://subodh-gupta.blogspot.com
Natesan Prabhakaran
Ranch Hand

Joined: Jul 11, 2006
Posts: 47
Connection is establised during the runtime and find correct database, table and query are executed in runtime, then how it is compiletime exception., i dont know how..? please explain.

thanks.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

Exceptions are ALWAYS thrown at runtime.

What you call CompileTimeException is actually called a checked exception. It differs from RuntimeException only in that you HAVE to catch or rethrow it.
Mostly, RuntimeExceptions are caused by mistakes by a programmer; often he just doesn't check if some assertion holds.
- IllegalArgumentException indicates a value has not been checked properly first
- NullPointerException indicates a value hasn't been checked against being null
- ArithmeticException indicates the programmer wanted to perform some arithmetic which isn't allowed (integer division by 0)

Checked exceptions on the other hand, are more often caused by external factors. A database can fail (SQLException), a hard drive or filesystem can fail (IOException), a network can fail (SocketException), etc. The programmer cannot check these things most of the times, and therefore is forced to handle the error.

Please note that a programmer can also throw checked exceptions to make sure other programmers are always aware of the exception, and don't just forget about them (which happens with NullPointerExceptions mostly).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
jQuery in Action, 2nd edition
 
subject: Sql Exception