rocket mass heater kickstarter
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

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Sql Exception" Watch "Sql Exception" New topic

Sql Exception

Natesan Prabhakaran
Ranch Hand

Joined: Jul 11, 2006
Posts: 47
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.


subodh gupta
Ranch Hand

Joined: Jul 23, 2007
Posts: 203

Can you make the situation more clear by asking the specific question.
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.

Rob Spoor

Joined: Oct 27, 2005
Posts: 19908

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).

How To Ask Questions How To Answer Questions
rocket mass heater kickstarter
subject: Sql Exception